Skip to content

rjzflynnbx/tampermonkey-one-stop-shop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 

Repository files navigation

Tampermonkey "One-Stop-Shop"

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.

What is a "tampermonkey demo"?

This kind of custom demo allows you to:

  1. Show data capture in Sitecore CDP/P on any website
  2. Publish Web Experiences on any website
  3. Publish and trigger Full Stack Experiences on any website

Installing Tampermonkey

Tampermonkey is a browser (Chrome, Firefox etc.) plugin. Just check their docs or Google or Youtube to figure out how to install the plugin.

Installing the Sitecore CDP/P JS library on a website with Tampermonkey

Go here for instructions.

Frequent Problems

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:

enter image description here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages