Third-party integrations
Google Analytics 360 connector
Section titled Google Analytics 360 connectorRead the related documentation ↗.
Adobe Analytics connector
Section titled Adobe Analytics connectorRead the related documentation ↗.
A/B Testing solutions
Section titled A/B Testing solutionsYou can send the variants from A/B Testing solution (ABTasty, Kameleoon, Monetate, Google Optimize, Dynamic Yield, Qubit, VWO, Optimizely, Usabilla, Maxymiser, Adobe Test and Target…)
Read the related documentation ↗.
Miscellaneous Implementation samples
Section titled Miscellaneous Implementation samplesAdblock detection
Section titled Adblock detectionIf you want to detect if the user is using Adblock, you could send this information using a custom var. The following code is an example on how to do it:
(function () { var test = document.createElement("div"); test.innerHTML = " "; test.className = "adsbox"; document.body.appendChild(test); window._uxa = window._uxa || []; if (test.offsetHeight === 0) window._uxa.push(["setCustomVariable", 1, "isAdblock", true]); else window._uxa.push(["setCustomVariable", 1, "isAdblock", false]); test.remove();})();Get Contentsquare session context (for integrations)
Section titled Get Contentsquare session context (for integrations)getSessionKey
Section titled getSessionKeyThe getSessionKey command allows for retrieving a unique Contentsquare session key. It’s a string that encodes both
a userId and a sessionNumber, in the form <userId>.<sessionNumber> (example: "59e73d8b-2730u283i20-6712c43aaab3.3"). You can also provide a callback function:
function csCallback(sessionKey) { const [userId, sessionNumber] = sessionKey.split("."); // do something with the session key}
window._uxa = window._uxa || [];_uxa.push(["getSessionKey", csCallback]);afterPageView
Section titled afterPageViewThe afterPageView command allows for executing a callback after the “natural” pageview or “artificial” pageview (trackPageview command).
You don’t need to wait for the Contentsquare tag to be fired to send this command.
If the command is called after the natural pageview, the callback is executed immediately and then after each
trackPageview. You can register multiple callbacks by calling the command multiple times.
The callback is called with a context which contains:
projectIdsessionKeypageNumberreplayConsentRequiredreplayConsent
context.sessionKey is a unique session identifier. It’s a string that encodes both a userId and a sessionNumber, in the
form <userId>.<sessionNumber> (example: "59e73d8b-2730u283i20-6712c43aaab3.3").
userId is a unique anonymous ID generated by Contentsquare.
sessionNumber is the position of the session in all the sessions tracked by Contentsquare for the same user (based
on cookie tracking). So if sessionNumber is 3, it means that it’s the third session tracked for this user.
Here’s an example which shows how to get the session context and use it in your callback:
function csCallback(context) { const projectId = context.projectId; const [userId, sessionNumber] = context.sessionKey.split("."); const pageNumber = context.pageNumber; // do something with the session context}
window._uxa = window._uxa || [];_uxa.push(["afterPageView", csCallback]);