|
|
|
|
|
|
|
|
import { recordTracksPageViewWithPageParams } from '@automattic/calypso-analytics'; |
|
|
import { resolveDeviceTypeByViewPort } from '@automattic/viewport'; |
|
|
import { retarget as retargetAdTrackers } from 'calypso/lib/analytics/ad-tracking'; |
|
|
import saveImpactAffiliateClickId from 'calypso/lib/analytics/impact-affiliate'; |
|
|
import { updateQueryParamsTracking } from 'calypso/lib/analytics/sem'; |
|
|
import { refreshCountryCodeCookieGdpr, saveCouponQueryArgument } from 'calypso/lib/analytics/utils'; |
|
|
import { gaRecordPageView } from './ga'; |
|
|
import { processQueue } from './queue'; |
|
|
import { referRecordPageView } from './refer'; |
|
|
|
|
|
export function recordPageView( urlPath, pageTitle, params = {}, options = {} ) { |
|
|
|
|
|
|
|
|
setTimeout( () => { |
|
|
|
|
|
params.device_type = resolveDeviceTypeByViewPort(); |
|
|
|
|
|
|
|
|
recordTracksPageViewWithPageParams( urlPath, params ); |
|
|
safeGoogleAnalyticsPageView( |
|
|
urlPath, |
|
|
pageTitle, |
|
|
options?.useJetpackGoogleAnalytics, |
|
|
options?.useAkismetGoogleAnalytics, |
|
|
options?.useA8CForAgenciesGoogleAnalytics |
|
|
); |
|
|
referRecordPageView(); |
|
|
saveImpactAffiliateClickId(); |
|
|
|
|
|
|
|
|
saveCouponQueryArgument(); |
|
|
updateQueryParamsTracking(); |
|
|
retargetAdTrackers( urlPath ); |
|
|
|
|
|
|
|
|
processQueue(); |
|
|
}, 0 ); |
|
|
} |
|
|
|
|
|
async function safeGoogleAnalyticsPageView( |
|
|
urlPath, |
|
|
pageTitle, |
|
|
useJetpackGoogleAnalytics = false, |
|
|
useAkismetGoogleAnalytics = false, |
|
|
useA8CForAgenciesGoogleAnalytics = false |
|
|
) { |
|
|
await refreshCountryCodeCookieGdpr(); |
|
|
gaRecordPageView( |
|
|
urlPath, |
|
|
pageTitle, |
|
|
useJetpackGoogleAnalytics, |
|
|
useAkismetGoogleAnalytics, |
|
|
useA8CForAgenciesGoogleAnalytics |
|
|
); |
|
|
} |
|
|
|