Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions extensions/cmp_interaction_tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@

function isAfterCMP() {
const hasCMPAfterCookie = window.utag.data['cp.utag_main_cmp_after'] ? (window.utag.data['cp.utag_main_cmp_after'] === 'true') : false;
const hasCMPAfterCookie_subdomain = window.utag.data['cp.utag_main_cmp_after_sub'] ? (window.utag.data['cp.utag_main_cmp_after_sub'] === 'true') : false;
const defaultVendorList = 'adobe_cmp,';
const hasVendors = !!window.utag.data.consentedVendors && window.utag.data.consentedVendors !== defaultVendorList;
const hasVendors_subdomain = !!window.utag.data['cp.cm_cv_list'] && window.utag.data['cp.cm_cv_list'] !== defaultVendorList;

// sportbild.bild.de needs special treatment because of sub-domain issues.
const subdomains = [
'sportbild.bild.de',
'm.sportbild.bild.de',
'shop.bild.de',
'angebot.bild.de',
'shopping.welt.de',
Expand All @@ -113,7 +116,7 @@
// sportbild.bild.de, shop.bild.de, offerpages needs special treatment because of sub-domain issues.
if ((window.utag.data['dom.domain']) && subdomains.indexOf(window.utag.data['dom.domain']) !== -1){
// hasCMPAfterCookie cannot be used here because it shares cookie with base domain
return hasVendors;
return hasCMPAfterCookie_subdomain || hasVendors_subdomain;
} else {
return hasCMPAfterCookie || hasVendors;
}
Expand Down Expand Up @@ -142,7 +145,9 @@
// Calling setScrollDepthProperties() will make the current page trackable as the _ppvPreviousPage of the next page view.
window.cmp._scrollDepthObj.setScrollDepthProperties(window.cmp);
}
window.cmp._campaignObj.setCampaignVariables(window.cmp, true);
if (window.cmp && window.cmp._campaignObj) {
window.cmp._campaignObj.setCampaignVariables(window.cmp, true);
}
}

function sendFirstPageViewEvent() {
Expand All @@ -153,16 +158,20 @@
}
}

function onMessageChoiceSelect(id, eventType) {
function onMessageChoiceSelect(messageType, id, eventType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the messageType added here used somewhere in the function? if yes, we would need to add it in our tests as well.

if (CONSENT_MESSAGE_EVENTS[eventType]) {
window.utag.data['cmp_events'] = CONSENT_MESSAGE_EVENTS[eventType];
exportedFunctions.sendLinkEvent(CONSENT_MESSAGE_EVENTS[eventType]);

if (eventType === 11 || eventType === 13) {
if ((eventType === 11 && (window.utag.data['dom.domain'] && window.utag.data['dom.domain'].includes('sportbild.bild.de'))) || (eventType === 13 && (window.utag.data['dom.domain'] && window.utag.data['dom.domain'].includes('sportbild.bild.de'))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ((eventType === 11 || eventType === 13) && window.utag.data['dom.domain'] && window.utag.data['dom.domain'].includes('sportbild.bild.de'))

{
window.utag.loader.SC('utag_main', {'cmp_after_sub': 'true'});
window.utag.data['cp.utag_main_cmp_after_sub'] = 'true';
} else{
window.utag.loader.SC('utag_main', {'cmp_after': 'true'});
window.utag.data['cp.utag_main_cmp_after'] = 'true';
}

if (eventType === 11) {
exportedFunctions.onUserConsent();
}
Expand All @@ -174,8 +183,13 @@
window.utag.data['cmp_events'] = eventType.purposeConsent ? (eventType.purposeConsent === 'all' ? PRIVACY_MANAGER_EVENTS.ACCEPT_ALL : PRIVACY_MANAGER_EVENTS.SAVE_AND_EXIT) : PRIVACY_MANAGER_EVENTS[eventType];
exportedFunctions.sendLinkEvent(window.utag.data['cmp_events']);
// Set cookie for first page view tracking.
window.utag.loader.SC('utag_main', {'cmp_after': 'true'});
window.utag.data['cp.utag_main_cmp_after'] = 'true';
if (window.utag.data['dom.domain'] && window.utag.data['dom.domain'].includes('sportbild.bild.de')){
window.utag.loader.SC('utag_main', {'cmp_after_sub': 'true'});
window.utag.data['cp.utag_main_cmp_after_sub'] = 'true';
}else{
window.utag.loader.SC('utag_main', {'cmp_after': 'true'});
window.utag.data['cp.utag_main_cmp_after'] = 'true';
}
}
}

Expand Down