Skip to content
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

Add decorate Links #406

Closed
wants to merge 7 commits into from
Closed
Changes from 5 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
42 changes: 42 additions & 0 deletions solutions/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,46 @@ export default function decorateLinkedPictures(main) {
});
}

/**
* Decorete links with adobe_mc parameter.
* @param {Element} selector
*/
function appendAdobeMcLinks(selector) {
try {
// eslint-disable-next-line no-undef
const visitor = Visitor.getInstance('0E920C0F53DA9E9B0A490D45@AdobeOrg', {
trackingServer: 'sstats.bitdefender.com',
trackingServerSecure: 'sstats.bitdefender.com',
marketingCloudServer: 'sstats.bitdefender.com',
marketingCloudServerSecure: 'sstats.bitdefender.com',
});
const wrapperSelector = document.querySelector(selector);
const hrefSelector = '[href*=".bitdefender."]';

wrapperSelector.querySelectorAll(hrefSelector).forEach((link) => {
const destinationURLWithVisitorIDs = visitor.appendVisitorIDsTo(link.href);

link.href = destinationURLWithVisitorIDs.replace(/MCAID%3D.*%7CMCORGID/, 'MCAID%3D%7CMCORGID');
});
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
}
}

function checkAEPDataCollection() {
// Check if Adobe Experience Platform Data Collection is loaded
if (window.adobe && window.adobe.target && window.adobe.target.getOffer) {
// Your custom code here
appendAdobeMcLinks('main');
// Stop checking, as AEP Data Collection is now loaded
// eslint-disable-next-line no-use-before-define
clearInterval(checkInterval);
}
}

// Set an interval to check every 100 milliseconds (adjust as needed)
andreibogdan marked this conversation as resolved.
Show resolved Hide resolved

/**
* Decorates the main element.
* @param {Element} main The main element
Expand Down Expand Up @@ -533,3 +573,5 @@ async function loadPage() {
}

loadPage();

const checkInterval = setInterval(checkAEPDataCollection, 100);
andreibogdan marked this conversation as resolved.
Show resolved Hide resolved