Skip to content

Commit

Permalink
Merge pull request #1293 from hlxsites/1266-salesforce-beacon
Browse files Browse the repository at this point in the history
1266-salesforce-beacon
  • Loading branch information
davenichols-DHLS authored Nov 7, 2024
2 parents 619f828 + 78ff60a commit 598c7fa
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
49 changes: 36 additions & 13 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ function loadGTM() {
}
// google tag manager -end

// SalesForce MCP - start

function loadEvergageScript() {
const script = document.createElement('script');
if (window.location.host === 'lifesciences.danaher.com') {
script.src = 'https://cdn.evgnet.com/beacon/v55685555553mx3rf3h3n3n3i091550196/danaher_ls_prod/scripts/evergage.min.js';
} else {
script.src = 'https://cdn.evgnet.com/beacon/v55685555553mx3rf3h3n3n3i091550196/danaher_ls_staging/scripts/evergage.min.js';
}
script.onload = function onEvergageLoad() {
};
script.onerror = function onEvergageError() {
};
document.head.appendChild(script);
}

/* eslint-disable no-console */
if (typeof OnetrustActiveGroups !== 'undefined' && OnetrustActiveGroups.includes("C0004")) {
loadEvergageScript();
}

// SalesForce MCP - end

// Adobe Target - start

window.targetGlobalSettings = {
Expand All @@ -59,14 +82,14 @@ function sendCoveoEventPage() {
const pdftitle = usp.get('title');

let cval = '';
if( pdfurl != null && pdfurl.length > 0){
if (pdfurl != null && pdfurl.length > 0) {
cval = window.location.origin + pdfurl;
} else {
cval = window.location.origin + window.location.pathname;
}

let title = '';
if( pdftitle != null && pdftitle.length > 0 ){
if (pdftitle != null && pdftitle.length > 0) {
title = pdftitle;
} else {
title = document.title;
Expand All @@ -77,7 +100,7 @@ function sendCoveoEventPage() {
accessToken,
`https://${organizationId}.analytics.org.coveo.com`,
);

coveoua('send', 'view', {
contentIdKey: 'permanentid',
contentIdValue: cval,
Expand All @@ -86,7 +109,7 @@ function sendCoveoEventPage() {
title: title,
location: document.location.href,
originLevel1: "DanaherMainSearch",
});
});
}

function sendCoveoEventProduct() {
Expand All @@ -100,19 +123,19 @@ function sendCoveoEventProduct() {

const cats = document.querySelector('.hero-default-content .categories');
let pcats = '';
if( cats != null ){
if (cats != null) {
pcats = cats.textContent.replaceAll('|', '/').replaceAll(',', '|');
}

coveoua('ec:addProduct', {
id: document.querySelector('.hero-default-content .sku')?.textContent,
id: document.querySelector('.hero-default-content .sku')?.textContent,
name: document.querySelector('.hero-default-content .title')?.textContent,
category: pcats,
price: 0,
brand: document.querySelector('.hero-default-content .brand')?.textContent
});

coveoua('ec:setAction', 'detail');
coveoua('ec:setAction', 'detail');
coveoua('send', 'event', {
"searchHub": "DanaherMainSearch"
});
Expand Down Expand Up @@ -152,9 +175,9 @@ loadScript('https://cdn.usefathom.com/script.js', attrs);
(function (c, o, v, e, O, u, a) {
a = 'coveoua';
c[a] = c[a]
|| function () {
(c[a].q = c[a].q || []).push(arguments);
};
|| function () {
(c[a].q = c[a].q || []).push(arguments);
};
c[a].t = Date.now();

u = o.createElement(v);
Expand Down Expand Up @@ -186,10 +209,10 @@ if (!window.location.hostname.includes('localhost')) {
loadGTM();
//loadAT();

if (isOTEnabled()){
if (getMetadata('template') === 'ProductDetail' && document.querySelector('h1') ) {
if (isOTEnabled()) {
if (getMetadata('template') === 'ProductDetail' && document.querySelector('h1')) {
sendCoveoEventProduct();
} else if(getMetadata('template') !== 'ProductDetail'){
} else if (getMetadata('template') !== 'ProductDetail') {
sendCoveoEventPage();
}
}
Expand Down
20 changes: 0 additions & 20 deletions scripts/scripts-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,6 @@ export function moveInstrumentation(from, to) {
);
}

/**
* SalesForce MCP
*/

function loadEvergageScript() {
const script = document.createElement('script');
if (window.location.host === 'lifesciences.danaher.com') {
script.src = 'https://cdn.evgnet.com/beacon/v55685555553mx3rf3h3n3n3i091550196/danaher_ls_prod/scripts/evergage.min.js';
} else {
script.src = 'https://cdn.evgnet.com/beacon/v55685555553mx3rf3h3n3n3i091550196/danaher_ls_staging/scripts/evergage.min.js';
}
script.onload = function onEvergageLoad() {
};
script.onerror = function onEvergageError() {
};
document.head.appendChild(script);
}

loadEvergageScript();

/**
* Get the Image URL from Scene7 and Optimize the picture
* @param {string} imageUrl
Expand Down
Loading

0 comments on commit 598c7fa

Please sign in to comment.