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

1266-salesforce-beacon #1293

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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 @@ -149,9 +172,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 @@ -183,10 +206,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
Loading