You can support visitor privacy by adding an opt-out function to your website. This lets a visitor disable Retention.com event tracking when they choose not to be tracked.
Before you begin
You’ll need your Retention.com account key.
Step 1: Add the opt-out function to your site
Add this JavaScript to your website:
function setOptOutCookie() {
document.cookie = "_EventConsentStatusGE=Optout; expires=Fri, 31 Dec 9999 23:59:59 GMT"; localStorage.setItem("_EventConsentStatusGE", "Optout");
}
function DoNotTrack(accountkey) {
setOptOutCookie();
if (typeof geq !== "undefined" && geq.doNotTrack) { geq.doNotTrack(accountkey);
}
}Step 2: Call the function when a visitor opts out
Only call this function after a visitor chooses not to be tracked.
DoNotTrack("YourAccountkeyHere");Replace YourAccountkeyHere with your Retention.com account key.
Important
Do not call this function for every visitor. If you call it when a visitor has not opted out, tracking will stop for that visitor and your contact collection may be affected.
Optional: Let visitors opt back in
If your site allows visitors to change their consent choice, you can also add an opt-back-in function.
function setOptBackInCookie() {
document.cookie = "_EventConsentStatusGE=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
localStorage.removeItem("_EventConsentStatusGE");
}
function optBackIn(accountkey) {
setOptBackInCookie();
if (typeof geq !== "undefined" && geq.track) {
geq.track(accountkey);
}
}Only call this when a visitor previously opted out and has now clearly opted back in.
optBackIn("YourAccountkeyHere");Shopify pixel opt-out
If you use the Retention.com Shopify pixel, opt-out requests are automatically recognized when geq.doNotTrack() is used.
For Shopify pages where third-party scripts may not run, such as checkout, you can send opt-out or opt-in events directly through Shopify.
Opt out
Shopify.analytics.publish("custom_geq", {
name: "doNotTrack",
data: { label: account.hashid }
});
Opt in
Shopify.analytics.publish("custom_geq", {
name: "track",
data: { label: scriptID }
});If you use a consent management tool
If you use a tool like OneTrust, we recommend:
Waiting to load the Retention.com script until consent is confirmed
Calling the opt-out function immediately if a visitor withdraws consent
Making sure the opt-out cookie and local storage value are preserved across sessions
What to know
If neither the opt-out nor opt-in function is called, Retention.com tracking will run once the script loads.
