How to Make Google Analytics Opt-out Links With ExactMetrics

When making changes to your website for EU compliance, you might consider giving your users an opt-out option. This allows visitors to click a link to opt-out of being tracked and appearing in your reports.

This might be a better option instead of having visitors opt-in. Requiring your visitors to consent before being tracked could lead to lost data since many visitors may not always take the time to opt-in.

Follow this guide to learn how to set up an opt-out option for your visitors:

The EU’s privacy laws affect websites owned by businesses located in Europe, and firms that interact with EU citizens (if located outside of Europe).

For an official explanation of the EUGDPR, check out eugdpr.org.

How to Allow Your Users to Opt-out of Google Analytics Tracking Through a plugin

Step 1. Log into your WordPress and go to Plugins » Add New. Search for the “Google Analytics Opt-out” plugin and install:

Then Activate to finish.

 

Step 2. Copy your measurement ID from the ExactMetrics » Settings » Google Authentication section, under “Active Profile”.

Then go to Settings » Analytics Opt-out and paste the tracking code into the UA- or GA-Code field:

You can ignore the MonsterInsights setting, the plugin works fine without it.

 

Step 3. If desired, you can use the banner by enabling Use Banner.

 

Enabling this option will display a strip on the bottom of the browser for visitors:

 

Step 4. To customize the banner text, insert the shortcode under the Visual tab in the editor. Find and click the Analytics Opt-out button:

 

Step 5. Then insert your custom text between the tags [google_analytics_optout] and [/google_analytics_optout].

 

Step 6. Make sure Integrate Shortcode is enabled.

 

Step 7. Customize your successful opt-out text in the Opt-Out Successful field, or leave blank.

 

Step 8. Give your visitors the option of hiding the banner by enabling the option Hide banner after closing.

 

Step 9. Then click Save Changes to finish.

How to Allow Your Users to Opt-out of Google Analytics Tracking With The Google Analytics Opt-Out Without the Banner

Step 1. If you’re not using the banner, leave Use Banner unchecked.

Step 2. In any page or blog post, click the Analytics Opt-out button in the visual editor.

 

Step 3. Insert the shortcode and customize the text between the tags [google_analytics_optout] and [/google_analytics_optout].

How to Allow Users to Opt-out of GA Tracking With HTML Code

You can also implement an opt-out option with HTML.

Our prefixed version of the function for opt-out is __gtagTrackerOptout.

Here’s an example of an opt-out link:

<a href="javascript:__gtagTrackerOptout()">Click here to opt-out of Google Analytics</a>.

Copy and paste this code into your website, whether in a custom HTML widget, page, or post, or your theme’s settings that inserts code in the footer.

Follow this example to learn how to insert the link in your sidebar using a Custom HTML Widget.

Step 1. While logged into your WordPress site, go to the Appearance » Widgets page.

Step 2. Drag and drop a Custom HTML Widget to the sidebar of your theme, or any other available widget section.

 

Step 3. Insert the code within the widget’s content textarea:

<a href="javascript:__gtagTrackerOptout()">Click here to opt-out of Google Analytics</a>

Step 4. Customize the text “Click here to opt-out of Google Analytics” as desired.

Step 5. Click Save to finish.

You did it! You’ve added an opt-out solution for your visitors.

FAQs

Can Users Opt Back In?

Users that opt-out cannot opt back in. The only way for them to be tracked again is if they clear their cookies (or if they expire).

Will This Ensure My Website is Compliant With the EU Cookie Law?

Legal Disclaimer: This addon is designed to automate some of the settings change required to be in compliance with various EU laws however due to the dynamic nature of websites, no plugin can offer 100% legal compliance. Please consult a specialist internet law attorney to determine if you are in compliance with all applicable laws for your jurisdictions and your use cases.

As a website operator, it is solely your responsibility to ensure that you are in compliance with all applicable laws and regulations governing your use of our plugin.

ExactMetrics, its employees/contractors, and other affiliated parties are not lawyers. Any advice given in our support, documentation, website, other mediums or through our services/products should not be considered legal advice and is for informational and/or educational purposes only and are not guaranteed to be correct, complete or up-to-date, and do not constitute creating/entering an Attorney-Client relationship.