rsionId);
});
};
const reportEvent = (eventName, eventParams) => {
const category = eventNameToConversionActionCategory[eventName];
const conversionAction = conversionActions.find(
(currentConversionAction) =>
currentConversionAction.category.category === category,
);
if (conversionAction) {
let conversionData = {
send_to: `${conversionAction.conversionId}/${conversionAction.conversionLabel}`,
};
switch (category) {
case 'PURCHASE': {
const { revenue, id, currency, coupon, ...params } = eventParams;
conversionData = {
...conversionData,
...paramsMapper({ revenue, id, currency, coupon }, channelParams),
transactionId: eventParams.id,
items: mapContents(params),
};
break;
}
default:
break;
}
gtag('event', 'conversion', conversionData);
}
};
let isBootstrapped = false;
const bootstrap = () => {
handleGoogleConsent();
loadGtag();
return loadConversionActions().then(() => {
isBootstrapped = true;
});
};
const bootstrapPromise = bootstrap();
const registerListener = () => {
window.wixDevelopersAnalytics.register(
'd6708a0e-5b2a-458e-8cfe-bdca240aa2ce',
(eventName, eventParams) => {
if (isBootstrapped) {
reportEvent(eventName, eventParams);
} else {
bootstrapPromise.then(() => {
reportEvent(eventName, eventParams);
});
}
},
);
};
window.wixDevelopersAnalytics
? registerListener()
: window.addEventListener('wixDevelopersAnalyticsReady', registerListener);
})();
top of page
bottom of page