How to Make Google Analytics Opt-out Links With MonsterInsights

Maybe you want to take one step in the direction of attempting to comply with the EU privacy laws, or you want to allow people to opt-out of your Google Analytics tracking without giving them login access.

It’s easy using MonsterInsights and an HTML link or plugin! When a user clicks the link, Google will stop tracking them, and they will not appear in your reports.

In this guide, you’ll find:


Why would you want to allow visitors to opt-out of your Google Analytics tracking? Well, the EU Cookie Law or EUGDPR is the most likely reason.

An official explanation of the EUGDPR can be found at eugdpr.org

The EU has privacy laws in place that affect websites owned by businesses located in Europe, as well as firms outside of Europe that interact with EU citizens. Webmasters can allow users to opt-out of the Google Analytics tracking for their site by following the steps below.

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

Step 1. Install the Google Analytics Opt-out plugin:

First, go to Plugins » Add New and search for the Google Analytics Opt-out plugin.

Next, click Install Now.

Finally, click Activate.

Step 2. Navigate to Settings » Analytics Opt-out. You’ll see some options:

Analytics Opt-out Options

Step 3. If you want to use the built-in banner, check Use Banner.

The banner is a strip that goes across the bottom of the browser window when visitors are on your site, so they don’t miss the notification:

Step 4. Under Opt-Out Banner-Text with the Visual Editor selected, click the Analytics Opt-out shortcode button.

Step 5. If you want to customize the text, then change the text between [google_analytics_optout] and [/google_analytics_optout].

Change text between shortcodes

Step 6. Next, leave Integrate Shortcode checked.

Integrate Shortcode

Step 7. Then, enter any desired custom text in the Opt-Out Successful section, or leave blank.

Opt-out Successful

Step 8. Check Hide banner after closing if you would like it to close.

Hide Banner After Closing

Step 9. Finally, leave custom CSS empty, and click Save Changes.

Custom CSS

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 don’t want to use the banner, then uncheck Use Banner.

The new Analytics Opt-out button is now in your visual editor.

Step 2. Go to any page or blog post and click the Analytics Opt-out button in the visual editor. 

 

Step 3. If you want to customize the text, then change the text between [google_analytics_optout] and [/google_analytics_optout].

And now any user that clicks that code will be opted-out of the Google Analytics tracking!

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

Next, we will show you how to allow your site visitors to opt out of GA tracking with a simple HTML link.

To reduce conflicts with other plugins as well as to follow our plugin standard JS, our prefixed version of the function for the opt-out is __gtagTrackerOptout.

An example opt-out link is as follows:

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

You may paste the above code anywhere you want it, such as a custom HTML widget, page, or post, or even your theme’s settings such as in the footer.

In this example, we’re going to show you how to put it in your Sidebar with a Custom HTML Widget.

Step 1. Go to Appearance » Widgets.

Step 2. Drag a Custom HTML Widget to the Sidebar of your theme if you have one (or any other Widget section, such as the footer, if you don’t).

Step 3. Paste the code:

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

into the Content section of the Custom HTML widget.

Step 4. Modify the text “Click here to opt-out of Google Analytics” to be in the voice and tone of your website if needed.

Step 5. Click Save to save the Widget Content.

That’s it! You’ve just added code to allow your site visitors to opt-out of Google Analytics tracking!

Want to stop Google Analytics from tracking logged in users? It’s easy with MonsterInsights and Google Analytics. Here’s how.

FAQs

Can Users Opt Back In?

No, they cannot. They will need to clear their cookies.

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.

MonsterInsights, 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.