How to Let Users Opt Out of Siteimprove Analytics Tracking
Summary
To allow visitors to opt out of tracking, you implement a JavaScript command on your website that stops Siteimprove Analytics tracking, and optionally provide a button, link, or toggle so users can control their tracking state.
Overview
To accommodate the wishes of visitors that do not want their visitor information tracked, Siteimprove has created a cookie for our customers to implement on their website(s).
See also the related article - IP Anonymization in Siteimprove Analytics.
Steps
Setup
Identify implementation approach
Please contact your development team or agency to set up the solution.
You can either:
- Set up a link/button that lets your visitors opt-out of being tracked
- Create an opt-out/opt-in toggle switch
Code
Setting up an Opt-Out Button or Link
Opt-Out from Siteimprove Analytics Tracking can be controlled via JavaScript by calling:
_sz.push(['notrack']);
After this command has been executed, the Analytics script will stop tracking the visitor.
Add opt-out link
The code can be placed within a link:
<a href="#" onclick="_sz.push(['notrack']); return false;">Opt-out of Siteimprove Analytics</a>
Add opt-in (undo opt-out) link
The following code can be used for creating an undo opt-out link (you might want to call it opt-in link):
<a href="#" onclick="_sz.push(['notrack', false]); return false;">Opt-In to Siteimprove Analytics again</a>
Toggle
The current state of tracking (Opt-In/Opt-Out) is read with:
_sz.tracking();
This could be useful in a dialog with the end-user, as for example like this:
_sz.push(['notrack', confirm('Are you being tracked: ' + (_sz.tracking() ? 'Yes' : 'No') + '.
Pres OK if you want to opt out, CANCEL otherwise')]);Understand tracking state storage
The tracking state is kept in a cookie in the end user's browser.
Implement toggle button
Implement an opt-in/opt-out switch (toggle):
Use the following button definition:
<button id="szOptOutIn">Opt out</button>
instead of:
<button onclick="_sz.push(['notrack', confirm('Are you being tracked:
' + (_sz.tracking() ? 'Yes' : 'No') + '. Press OK if you want to opt out, CANCEL otherwise')]);">
Opt Out or Opt In</button>as seen above in the end-user dialog example.
Add this code on your page where you want to have your Opt-out/Opt-in button:
<button id="szOptOutIn">Opt out</button>
<script type="text/javascript">
function changeOptSetting(obj, txtOptIn, txtOptOut) { if(_sz){ obj.innerHTML=_sz.tracking()?txtOptOut:txtOptIn; obj.onclick = function() { _sz.push(['notrack', _sz.tracking()]); obj.innerHTML=_sz.tracking()?txtOptOut:txtOptIn; }; } } changeOptSetting(document.getElementById("szOptOutIn"), "Opt In", "Opt Out");
</script>Confirm tracking behavior
Use _sz.tracking() to confirm whether tracking is currently enabled or disabled.
Did you find it helpful? Yes No
Send feedback