MCPcopy
hub / github.com/ampproject/amphtml / getCsiAmpAnalyticsVariables

Function getCsiAmpAnalyticsVariables

ads/google/a4a/utils.js:640–656  ·  view source on GitHub ↗
(analyticsTrigger, a4a, qqid)

Source from the content-addressed store, hash-verified

638 * @return {!JsonObject}
639 */
640export function getCsiAmpAnalyticsVariables(analyticsTrigger, a4a, qqid) {
641 const {win} = a4a;
642 const ampdoc = a4a.getAmpDoc();
643 const navStart = getNavigationTiming(win, 'navigationStart');
644 const vars = /** @type {!JsonObject} */ ({
645 'correlator': getCorrelator(win, ampdoc),
646 'slotId': a4a.element.getAttribute('data-amp-slot-index'),
647 'viewerLastVisibleTime': ampdoc.getLastVisibleTime() - navStart,
648 });
649 if (qqid) {
650 vars['qqid'] = qqid;
651 }
652 if (analyticsTrigger == 'ad-render-start') {
653 vars['scheduleTime'] = a4a.element.layoutScheduleTime - navStart;
654 }
655 return vars;
656}
657
658/**
659 * Extracts configuration used to build amp-analytics element for active view

Callers 3

test-utils.jsFile · 0.90
getA4aAnalyticsVarsMethod · 0.90
getA4aAnalyticsVarsMethod · 0.90

Calls 5

getAttributeMethod · 0.80
getNavigationTimingFunction · 0.70
getCorrelatorFunction · 0.70
getAmpDocMethod · 0.45
getLastVisibleTimeMethod · 0.45

Tested by

no test coverage detected