/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
client/lib/analytics/ad-tracking/parsely.ts
32 строки
891 B
Brian Willis
Stop firing Parsely pageview on script load (#86855)
26 янв 2024, 02:11
Не верифицирован
26 янв 2024, 02:11
304ebfd
Код
Авторство
О чём код?
import { loadScript } from '@automattic/load-script'; import { mayWeTrackByTracker } from '../tracker-buckets'; import { PARSLEY_SCRIPT_URL } from './constants'; /** * We'll be accessing PARSELY from the window object. */ declare global { interface Window { PARSELY: { autotrack: boolean; conversions: { trackPurchase: ( label: string ) => void; }; }; } } /** * Loads the Parsely script, if the user has consented to tracking, * and tracking is allowed by the current environment. * @returns Promise<void> */ export const loadParselyTracker = async (): Promise< void > => { // Are we allowed to track (user consent, e2e, etc.)? if ( ! mayWeTrackByTracker( 'parsely' ) ) { throw new Error( 'Tracking is not allowed' ); } window.PARSELY = { ...window.PARSELY, autotrack: false }; // Load the Parsely Tracker script await loadScript( PARSLEY_SCRIPT_URL ); };