Skip to content

Trac 2265 one tag #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
37 changes: 21 additions & 16 deletions extensions/cmp/cmp_interaction_tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const CONSENT_MESSAGE_EVENTS = {
11: 'cm_accept_all',
12: 'cm_show_privacy_manager',
13: 'cm_reject_all',
5: 'cm_subscribe_pur',
};
const PRIVACY_MANAGER_EVENTS = {
Expand All @@ -18,27 +19,26 @@
// Tealium profile to Adobe TagId mapping.
const TEALIUM_PROFILES = {
'abo-autobild.de': 23,
'ac-autobild': 10,
'ac-computerbild': 9,
'ac-autobild': 1,
'ac-computerbild': 3,
'ac-wieistmeineip': 4,
'asmb-metal-hammer.de': 22,
'asmb-musikexpress.de': 14,
'asmb-rollingstone.de': 16,
'bild-bild.de': 12,
'bild-fitbook.de': 40,
'bild-myhomebook.de': 37,
'bild-petbook.de': 82,
'bild-sportbild.de': 16,
'bild-stylebook.de': 30,
'bild-techbook.de': 82,
'bild-travelbook.de': 42,
'bild-bild.de': 5,
'bild-fitbook.de': 30,
'bild-myhomebook.de': 30,
'bild-petbook.de': 78,
'bild-stylebook.de': 19,
'bild-techbook.de': 68,
'bild-travelbook.de': 34,
'bild-offer': 24,
'bild': 386,
'bz-bz-berlin.de': 9,
'bz-bz-berlin.de': 6,
'cbo-computerbild.de': 25,
'shop.bild': 181,
'spring-premium' : 135,
'welt': 233,
'welt': 155,
'welt-shop.welt.de': 28
};

Expand All @@ -64,7 +64,7 @@
getABTestingProperties,
onUserConsent,
sendFirstPageViewEvent,
hasUserGrantedConsent,
hasUserDeclinedConsent,
isAfterCMP,
notPurUser
};
Expand Down Expand Up @@ -99,6 +99,8 @@
exportedFunctions.setABTestingProperties(data);
}

// User can jump over different subdomains with different layers
// Cookie utag_main_cmp_after support to differ between them
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;
Expand All @@ -107,6 +109,7 @@
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.
// subdomains sometimes use different layer
const subdomains = [
'sportbild.bild.de',
'm.sportbild.bild.de',
Expand All @@ -117,7 +120,7 @@
'bildplusshop.bild.de',
'digital.welt.de'
];
// sportbild.bild.de, shop.bild.de, offerpages needs special treatment because of sub-domain issues.
// sportbild.bild.de, shop.bild.de, offerpages needs special treatment because of sub-domain issues/different layers.
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 hasCMPAfterCookie_subdomain || hasVendors_subdomain;
Expand All @@ -126,7 +129,7 @@
}
}

function hasUserGrantedConsent() {
function hasUserDeclinedConsent() {
const consentedVendors = window.utag.data['cp.cmp_cv_list'] || window.utag.data['cp.cm_cv_list'] || '';
const hasUserGivenConsent = consentedVendors.includes('adobe_analytics');
const isAfterCMP = exportedFunctions.isAfterCMP();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why the function name is changed without changing the functionality. The return value still corresponds to if the user has granted consent or not.

Expand All @@ -135,7 +138,7 @@
}

function sendLinkEvent(label) {
if (!exportedFunctions.hasUserGrantedConsent() && exportedFunctions.notPurUser()) {
if (!exportedFunctions.hasUserDeclinedConsent() && exportedFunctions.notPurUser()) {
window.utag.link({
'event_name': 'cmp_interactions',
'event_action': 'click',
Expand Down Expand Up @@ -218,6 +221,8 @@
}
}

// user is PUR subscriber, we are not allowed to track
// if WHOAMI then user_hasPurSubscription2, if Aubi/Cobi/BOOKs Cookie _cpauthhint
function notPurUser() {
if (window.utag.data.user_hasPurSubscription2 === 'true' || window.utag.data['cp._cpauthhint'] === '1') {
return false;
Expand Down
2 changes: 1 addition & 1 deletion extensions/doPlugins/doPlugins_global.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ s._utils = {
return ARTICLE_TYPES.indexOf(pageType) !== -1;
},
isFirstPageView: function () {
return !!window.cmp;
return window.utag.data.cmp_event_status == 'cmpuishown';
},
isValidURL: function (urlString) {
try {
Expand Down
37 changes: 18 additions & 19 deletions tests/cmp/cmp_interaction_tracking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ const browserMocks = require('../mocks/browserMocks');

const TEALIUM_PROFILES = [
{profileName: 'abo-autobild.de', tagId: 23},
{profileName: 'ac-autobild', tagId: 10},
{profileName: 'ac-computerbild', tagId: 9},
{profileName: 'ac-autobild', tagId: 1},
{profileName: 'ac-computerbild', tagId: 3},
{profileName: 'asmb-metal-hammer.de', tagId: 22},
{profileName: 'asmb-musikexpress.de', tagId: 14},
{profileName: 'asmb-rollingstone.de', tagId: 16},
{profileName: 'bild-bild.de', tagId: 12},
{profileName: 'bild-fitbook.de', tagId: 40},
{profileName: 'bild-myhomebook.de', tagId: 37},
{profileName: 'bild-petbook.de', tagId: 82},
{profileName: 'bild-sportbild.de', tagId: 16},
{profileName: 'bild-stylebook.de', tagId: 30},
{profileName: 'bild-techbook.de', tagId: 82},
{profileName: 'bild-travelbook.de', tagId: 42},
{profileName: 'bild-bild.de', tagId: 5},
{profileName: 'bild-fitbook.de', tagId: 30},
{profileName: 'bild-myhomebook.de', tagId: 30},
{profileName: 'bild-petbook.de', tagId: 78},
{profileName: 'bild-stylebook.de', tagId: 19},
{profileName: 'bild-techbook.de', tagId: 68},
{profileName: 'bild-travelbook.de', tagId: 34},
{profileName: 'bild-offer', tagId: 24},
{profileName: 'bild', tagId: 386},
{profileName: 'bz-bz-berlin.de', tagId: 9},
{profileName: 'bz-bz-berlin.de', tagId: 6},
{profileName: 'cbo-computerbild.de', tagId: 25},
{profileName: 'shop.bild', tagId: 181},
{profileName: 'spring-premium', tagId: 135},
{profileName: 'welt', tagId: 233},
{profileName: 'welt', tagId: 155},
{profileName: 'welt-shop.welt.de', tagId: 28}
];

Expand Down Expand Up @@ -249,27 +248,27 @@ describe('CMP Interaction Tracking', () => {
});
});

describe('hasUserGrantedConsent()', () => {
describe('hasUserDeclinedConsent()', () => {
it('should be false if user consented to Adobe Analytics tracking', function () {
window.utag.data['cp.cmp_cv_list'] = 'any-vendor,adobe_analytics';
let result = cmpInteractionTracking.hasUserGrantedConsent();
let result = cmpInteractionTracking.hasUserDeclinedConsent();
expect(result).toBe(true);
});
});

describe('sendLinkEvent()', () => {
let hasUserGrantedConsentMock;
let hasUserDeclinedConsentMock;
let notPurUserMock;

beforeEach(() => {
hasUserGrantedConsentMock = jest.spyOn(cmpInteractionTracking, 'hasUserGrantedConsent').mockImplementation();
hasUserDeclinedConsentMock = jest.spyOn(cmpInteractionTracking, 'hasUserDeclinedConsent').mockImplementation();
notPurUserMock = jest.spyOn(cmpInteractionTracking, 'notPurUser').mockImplementation().mockReturnValue(true);
});

it('should call sendLinkEvent() function with correct arguments if user has not already declined consent', () => {
const anyLabel = 'any-label';
setABTestingProperties();
hasUserGrantedConsentMock.mockReturnValue(false);
hasUserDeclinedConsentMock.mockReturnValue(false);
cmpInteractionTracking.sendLinkEvent(anyLabel);
expect(window.utag.link).toHaveBeenLastCalledWith(
{
Expand All @@ -283,14 +282,14 @@ describe('CMP Interaction Tracking', () => {

it('should NOT call sendLinkEvent() function if user has declined consent', () => {
const anyLabel = 'any-label';
hasUserGrantedConsentMock.mockReturnValue(true);
hasUserDeclinedConsentMock.mockReturnValue(true);
cmpInteractionTracking.sendLinkEvent(anyLabel);
expect(window.utag.link).not.toHaveBeenCalled();
});

it('should NOT call sendLinkEvent() function if user is PUR subscriber', () => {
const anyLabel = 'any-label';
hasUserGrantedConsentMock.mockReturnValue(true);
hasUserDeclinedConsentMock.mockReturnValue(true);
notPurUserMock.mockReturnValue(false);
cmpInteractionTracking.sendLinkEvent(anyLabel);
expect(window.utag.link).not.toHaveBeenCalled();
Expand Down
7 changes: 4 additions & 3 deletions tests/doplugins/doplugins_utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ describe('s_utils', () => {
});

describe('isFirstPageView', () => {
it('should return true if an global object with name cmp exists', () => {
window.cmp = {};
it('should return true if cmp_event_status cmpuishown', () => {
window.utag.data.cmp_event_status = 'cmpuishown';
const result = s._utils.isFirstPageView();

expect(result).toBe(true);
});

it('should return false if there is no global object with the name cmp', () => {
it('should return false if cmp_event_status is not cmpuishown', () => {
window.utag.data.cmp_event_status = 'any-status';
const result = s._utils.isFirstPageView();

expect(result).toBe(false);
Expand Down
Loading