# Opt-out from Tracking

Using CountUp, by default every visitor to your site is tracked. This helps you understand user behavior and preferences. However sometimes you might want to exclude visits from tracking:

  • Excluding Your Own Visits: Whether you're making updates, testing new features, or if you're a beta tester or team member, you might not want to influence the analytics data with your own visits. By excluding your visits, you can ensure the data you collect truly represents your audience's behavior.

  • Allowing Site Visitors to Opt Out: Respecting user privacy is paramount. Some visitors, due to privacy concerns or personal preferences, may wish to opt out of tracking. Providing an option for them underlines your commitment to their privacy.

# How opt out works

Many analytics tools exclude tracking by IP addresses. However, at CountUp, we prioritize user privacy. Storing IP addresses isn't in line with our commitment to GDPR compliance. So, how do we achieve exclusions without IP addresses? Enter: browser's localStorage.

LocalStorage is a part of web storage that allows websites to store data in a user's web browser. Unlike cookies, which have expiration dates, data in localStorage remains until explicitly deleted. By setting a special flag in localStorage, we can instruct CountUp not to track a user's visits, ensuring exclusions while prioritizing privacy.

# Allow exlcusion via a script on a page

For ease of use, we've created a basic HTML opt-out page, that includes a script to set the LocalStorage flag. You can deploy this page on your website to offer visitors an opt-out mechanism. You can download the template here:

Opt-Out Template (HTML)
countup-opt-out.html 974B

If you prefer to implement the opt-out page yourself, feel free to use the following JavaScript functions as a starting point:

function optOutFromCountUp() {
  localStorage.setItem('countup_ignore', 'true');
}

function optInToCountUp() {
  localStorage.setItem('countup_ignore', 'false');
}

function isOptedOutFromCountUp() {
  localStorage.getItem('countup_ignore') === 'true';
}

You can invoke these functions by click on a button or when toggling a checkbox for example and to show the opt-out status.

# Manually exclude from tracking

If you only want to exclude a specific device without having to implement a script, you can also manually set the exclusion flag in your browser's localStorage:

  1. Navigate to the website you'd like to exclude your visits from.
  2. Launch the web console in your browser. In Firefox or Chrome, this is done by pressing F12, then selecting the "Console" tab.
  3. Copy and paste the following command into the console, then press enter:
localStorage.countup_ignore = 'true';

To resume tracking of your visits:

  1. Visit the desired site and open the web console.
  2. Enter the following command and press enter:
delete localStorage.countup_ignore;