Share
Explore

Header Statistic Origins (DEPRECATED)

Where is the data coming from? How are we crunching the numbers?
NG
Nick Gentile
This document has been copied and moved somewhere else:
This document is intended to enable collaboration for both the header statistics’ api integrations and mathematical calculations.
NB: All queries are duplicated for the previous period using the previous start/end dates as params and renaming the as aliases with the prefix previous. Ex: spend as linearSpend & previousLinearSpend. For the sake of being concise, I’ll exclude the duplicity from the query column (although the actual graphql file has them).
NB: For the Delta Calculation column, if we apply the getDelta function, we are applying the following formula for percentage change:
Screen Shot 2021-09-08 at 2.08.55 PM.png
This value is formatted with formatPercent to achieve the final, formatted percentage string.
If the denominator (previous value) is zero, we return null and do not show percentage change.
NB: The Title column is color coded based on whether or not we have consensus agreement the query and calculation is correct.
Red - the stat is probably not being queried/calculated correctly
Yellow - the stat is most likely being queried/calculated correctly, but not confirmed
Green - consensus agreement the stat is being queried and calculated correctly
NB: You will notice that some of the calculations include both streaming and linear stats. This is because the queries are conditional. For example, if we are only querying for linear stats, the streaming stats will be 0.
Header Stats
0
Search
Title
Query
Value Calculation
Delta Calculation
1
Spend
Linear
campaignPerformance(slug, primaryMetric, start, end, networkTags)
→ networkAnalysis
→ totalPerformance
→ spend as linearSpend
Streaming
company(slug)
→ streamingPerformances(start, end)
→ totalSpend as streamingSpend

spend = linearSpend + streamingSpend

previousSpend =
previousLinearSpend + previousStreamingSpend

getDelta(previousSpend, spend)
2
Impressions
NB: I’m getting these values back as strings from the api, something seems awry
Linear
campaignPerformance(slug, primaryMetric, start, end, networkTags)
→ networkAnalysis
→ totalPerformance
→ totalImpressions as linearImpressions
Streaming
company(slug)
→ streamingPerformances(start, end)
→ totalImpressions as streamingImpressions

impressions = linearImpressions + streamingImpressions

previousImpressions =
previousLinearImpressions + previousStreamingImpressions
getDelta(previousImpressions, impressions)
3
Reach
NB: I’m not sure if this is the correct api.
Linear
company(slug)
→ linearReachFrequency(start, end, WEEK)
→ reach as linearReach
Streaming
company(slug)
→ streamingReachFrequency(start, end, WEEK)
→ reach as streamingReach

NB: The api returns a list of R/F objects. Do I take the average of all those values?
TODO: resolve how to query/calculate Reach
reach = linearReach + streamingReach
previousReach =
previousLinearReach + previousStreamingReach

getDelta(previousReach, reach)
4
Mean Frequency
5
Lift
NB: When querying for lift, we get both the primary metric lift and the secondary metric lift. While we add these two together to get the totalLift, the underlying components of the equation are also used to derive CPX and CPA, respectively.
Linear - Primary Metric
campaignPerformance(slug, primaryMetric, start, end, networkTags)
→ networkAnalysis
→ totalPerformance
→ lift as primaryLinearLift
Linear - Secondary Metric
campaignPerformance(slug, secondaryMetric, start, end, networkTags)
→ networkAnalysis
→ totalPerformance
→ lift as secondaryLinearLift
Streaming
company(slug)
→ streamingPerformances(start, end)
→ totalLift(primaryMetric) as primaryStreamingLift
→ totalLift(secondaryMetric) as secondaryStreamingLift

totalPrimaryLift = primaryLinearLift + primaryStreamingLift
totalSecondaryLift = secondaryLinearLift + secondaryStreamingLIft
previousTotalPrimaryLift =
previousPrimaryLinearLift + previousPrimaryStreamingLift
previousTotalSecondaryLift =
previousSecondaryLinearLift + previousSecondaryStreamingLIft

lift = totalPrimaryLift + totalSecondaryLift
previousLift =
previousTotalPrimaryLift + previousTotalSecondaryLift
getDelta(previousLift, lift)
6
CPA
NB: see above ‘Spend’ and ‘Lift’ queries
NB: CPA is calculated using lift from the secondary metric
cpa = spend / totalSecondaryLift
previousCPA = previousSpend / previousTotalSecondaryLift
cpaDelta = cpa - previousCPA
7
CPX
NB: see above ‘Spend’ and ‘Lift’ queries
NB: CPX is calculated using lift from the primary metric
cpx = spend / totalPrimaryLift
previousCPX = previousSpend / previousTotalPrimaryLift
cpxDelta = cpx - previousCPX
8
ROAS
There are no rows in this table

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.