On this page you will find all of the information you need to know about how to use TamperMonkey to create a custom Sitecore CDP/P demo.
This kind of custom demo allows you to:
- Show data capture in Sitecore CDP/P on any website
- Publish Web Experiences on any website
- Publish and trigger Full Stack Experiences on any website
Tampermonkey is a browser (Chrome, Firefox etc.) plugin. Just check their docs or Google or Youtube to figure out how to install the plugin.
Go here for instructions.
If a script is not loading/working first check your matcher and ensure its working.
Copy the URL directly from the address bar in your browser.
When the matcher is working - on your target website you should see a '1' icon next to the tampermonkey plugin icon that indicates that one script is loaded.
If still not working after you have confirmed the matcher works then open the developer console and look for errors:
Content security policy error:
Install the Allow CORS: Access-Control-Allow-Origin Chrome plugin, configure, and re-try.
CORS error:
Install the Disable Content-Security-Policy Chrome plugin, configure, and re-try.
Subdomain tracking not working
Configure the cookie_domain setting in your script
Page views not triggering, website is a SPA/React/Angular etc. app
Add the following code to the tampermonkeys script
let lastUrl = location.href;
new MutationObserver(() => {
const url = location.href;
if (url !== lastUrl) {
lastUrl = url;
onUrlChange();
}
}).observe(document, { subtree: true, childList: true });
function onUrlChange() {
var event = {
channel: CHANNEL,
language: LANG,
currency: CURRENCY,
page: window.location.pathname + window.location.search
};
// Send VIEW event
window.engage.pageView(event);
console.log("Sitecore Engage SDK Sent VIEW event")
}
Place the above code before the main() function is called: