Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
SELECT
  performedAt, eventMeta.id AS conversionUuid, conversionId,
  processing.customerId AS customerId,
  (select value from unnest(freeParameters) where key ='uv1') AS userValue1,
  (select value from unnest(freeParameters) where key ='uv2') AS userValue2,
  (select value from unnest(freeParameters) where key ='uv3') AS userValue3,
 FROM `i19s-insights.insights.insights_conversion`
 WHERE DATE(performedAt) = current_date()
     AND processing.totalWinnerCount > 0
     AND (select value from unnest(freeParameters) where key ='uv3') LIKE '%Madrid%'

...

Untracked

Total number of untracked conversions for a given advertiser

Code Block
languagesql

  SELECT sum(cnt) count
  FROM `i19s-insights.insights.trail_untracked_cnt` 
  WHERE DATE(requestDate) = current_date()
    AND advertiserId = <advertiserId>
    AND requestType = 'Conversion' 

...

Number of untracked conversions by reason for a given advertiser

Code Block
languagesql

  SELECT reason, sum(cnt) count
  FROM `i19s-insights.insights.trail_untracked_cnt` 
  WHERE DATE(requestDate) = current_date()
    AND advertiserId = <advertiserId>
    AND requestType = 'Conversion' 
  GROUP BY 1   

...

Attribution

Total number of successfully processed conversions for a given advertiser

Code Block
languagesql

  SELECT sum(count) count
  FROM `i19s-insights.insights.insights_conversion_hourly` 
  WHERE DATE(performanceHour) = current_date()
    AND advertiserId = <advertiserId>

...

Total number of attributed conversions for a given advertiser

Code Block
languagesql

  SELECT count(*)
  FROM `i19s-insights.insights.insights_conversion`
  WHERE DATE(performedAt) = current_date()    
    AND advertiserId = <advertiserId>    
    AND processing.totalWinnerCount > 0

...

Total number of unattributed conversions having an empty user journey for a given advertiser

Code Block
languagesql

  SELECT count(*)
  FROM `i19s-insights.insights.insights_conversion`
  WHERE DATE(performedAt) = current_date()    
    AND advertiserId = <advertiserId>
    AND processing.totalWinnerCount = 0  
    AND array_length(userJourney) = 0

...

Number of decline reasons by touchpoint type and channel for a given advertiser

Code Block
languagesql

with x as (
    select
(
    select as struct
    j.touchpointType,
    case
        when j.processing.click is not null then j.processing.click.channelId
        when j.processing.view is not null then j.processing.view.channelId
    end as channelId,
    case
        when j.processing.click is not null then j.processing.click.requestDeclineReasonAvro
        when j.processing.view is not null then j.processing.view.requestDeclineReasonAvro
    end as declineReason
) reasons,
ic.processing.trackingId
from `i19s-insights.insights.insights_conversion` ic, unnest(userJourney) j
where date(ic.performedAt) = current_date()
and advertiserId = <advertiserId>
and ic.processing.totalWinnerCount = 0
and (
        j.processing.click.requestDeclineReasonAvro is not null and j.processing.click.requestDeclineReasonAvro != 'UNKNOWN' 
    or
        j.processing.view.requestDeclineReasonAvro is not null and j.processing.view.requestDeclineReasonAvro != 'UNKNOWN'
    )
)

,r as (
    select reasons.touchpointType, tc.alias as channelName, reasons.declineReason, count(distinct trackingId) count from x
    left outer join `i19s-insights.insights.trail_channel` tc on reasons.channelId = tc.channelId
    where reasons is not null
    group by 1,2,3
)

select array_agg(struct(touchpointType, channelName, declineReason, count) order by count desc) reason, sum(count) as countTotal
from r
order by countTotal desc

...

Number of decline reasons by touchpoint type, channel, real and http referrer host for a given advertiser

Code Block
languagesql

with x as (
    select
(
    select as struct
    j.touchpointType,
    case
        when j.processing.click is not null then j.processing.click.channelId
        when j.processing.view is not null then j.processing.view.channelId
    end as channelId,
    case
        when j.processing.click is not null then j.processing.click.requestDeclineReasonAvro
        when j.processing.view is not null then j.processing.view.requestDeclineReasonAvro
    end as declineReason,
    case
        when j.processing.click is not null then j.processing.click.realReferer.host
        when j.processing.view is not null then j.processing.httpReferer.host
    end as realReferrerHost,    
    j.processing.httpReferer.host as httpReferrerHost
) reasons,
ic.processing.trackingId
from `i19s-insights.insights.insights_conversion` ic, unnest(userJourney) j
where date(ic.performedAt) = current_date()
and advertiserId = <advertiserId>
and ic.processing.totalWinnerCount = 0
and (
        j.processing.click.requestDeclineReasonAvro is not null and j.processing.click.requestDeclineReasonAvro != 'UNKNOWN' 
    or
        j.processing.view.requestDeclineReasonAvro is not null and j.processing.view.requestDeclineReasonAvro != 'UNKNOWN'
    )
)

,r as (
    select reasons.touchpointType, tc.alias as channelName, reasons.realReferrerHost, reasons.httpReferrerHost, reasons.declineReason, count(distinct trackingId) count from x
    left outer join `i19s-insights.insights.trail_channel` tc on reasons.channelId = tc.channelId
    where reasons is not null
    group by 1,2,3,4,5
)

select array_agg(struct(touchpointType, channelName, realReferrerHost, httpReferrerHost, declineReason, count) order by count desc) reason, sum(count) as countTotal
from r
order by countTotal desc

...

Advanced

...

Access for Free parameters of User Journey Touchpoints.

...