Additional cookie blocking
Google Analytics & Facebook Pixel can track the acquisition of your store visitors, what pages they frequently visit, how much time they spend on each page, and much more.
In this article, we will take a look at the additional cookie blocking for Google Analytics, Facebook Pixel and Google Tag Manager. We will help you make your store visitors feel more secure.
How to additionally block the Google Analytics
Google Analytics creates cookies on a page load and our GDPR/CCPA app removes them on every refresh. As we are constantly deleting the cookies each page load is considered a new visitor session. That way, Google cannot fully track what the customer is doing on your web store. We chose this method because of Shopify's limitations. They are preventing us from getting the tracking codes for each store. Although, there is one more thing you can do if you want to add additional protection for your visitors.
Follow the steps below:
-
Open Shopify Admin.
-
Click on the Online Store link in the left menu bar.
-
Click on the "Action" dropdown button and select "Edit Code" from there.
- A new page will open with a list of files on the left side of the screen. Open the "theme.liquid"
- Find the string "</head>" in there.
-
When you do, add the following snippet before "</head>":
<script> var gaProp='UA-XXXXXX-X'; var iac=(document.cookie.match(/^(?:.*;)?\s*cookieconsent_preferences_disabled\s*=\s*([^;]+)(?:.*)?$/)||[,null])[1]; if(iac!=null&&iac.indexOf('analytics')>= 0){window['ga-disable-'+gaProp]=true;} } </script>
Note: Make sure to replace the "UA-XXXXXX-X" string with your Google Analytics tracking ID.
-
After you add the snippet click on the Save button.
Check the video for more details:
Facebook Pixel additional blocking
For the Facebook Pixel, the procedure is the same:
-
Open Shopify Admin.
-
Click on the Online Store link in the left menu bar.
-
Click on the "Action" dropdown button and select "Edit Code" from there.
-
Find the string "</head>" in there.
- When you do, add the following snippet before "</head>":
<script> !function(){var e=null,n=[],t=(document.cookie.match(/^(?:.*;)?\s*cookieconsent_preferences_disabled\s*=\s*([^;]+)(?:.*)?$/)||[,null])[1]; Object.defineProperty(window,"fbq",{get:function(){return e},set:function(o){Object.defineProperty(o,"queue",{get:function(){return null!=t&&t.indexOf("marketing")>=0?[]:n},set:function(){}}),e=o}})}(); } </script>
-
After you add the snippet click on the Save button.
We use these two scripts so that the blocking is always correct for people who give up cookies.
Shopify offers a feature for additional cookie blocking called Limit tracking for customers. This feature limits Shopify’s tracking of online store customers and notifies any third-party apps that you have installed in your store to limit their tracking. You can enable it for customers in Europe by following these steps:
-
In your Shopify admin, click Online Store.
-
Click Preferences > Customer privacy.
-
Click Limit tracking for customers in Europe.
After you have added additional cookie blocking to Google Analytics or Facebook Pixel through our app, you can go and click on the Limit tracking for customers in Europe option, as well. That way Shopify will make additional cookie blocking to Google Analytics and Facebook Pixel including on the Checkout page.
Your customers in California can opt-out of the sale of their data, too. You can enable Limit the third-party sale of your California customers’ data in your Shopify store settings. You are able to do it with just a few clicks:
-
In your Shopify admin, click Online Store.
-
Click Preferences > Customer privacy.
-
Click Limit the third-party sale of your California customers’ data.
Keep in mind that when you share your customer’s data with third parties, Shopify can't control how the data is used. It can only inform how data should be handled.
Shopify can’t control if a third-party app or script tracks customers. That is why they provide a consent tracking API for integration. We have integrated this consent tracking API into our GDPR/CCPA app. However, this consent tracking API has some limitations. For example, in our app, you can choose which cookies to block, either Facebook Pixel ones or Google Analytics ones. However, Shopify doesn't offer this option, so if the Limit tracking for customers feature is enabled all the cookies for Facebook Pixel & Google Analytics will be blocked.
In order to add additional blocking follow the steps in the video
Blocking the Google Tag Manager
Google Tag Manager blocking is also available, and it can be done with an additional script. Based on a Container ID the script below will block the Google Tag Manager.
Google Tag Manager is set based on a condition, which checks one of the cookies, that are set by our app. This cookie is storing information on which exact cookie group is currently blocked. This depends on the initial state or the preferences of each customer. When the initial state is set to block the Analytics cookie group or the customer opts-out, the script which is setting the Tag Manager will not be executed.
Check the instruction on how you can apply the script:
-
Open Shopify Admin.
-
Click on the Online Store link in the left menu bar.
-
Click on the "Action" dropdown button and select "Edit Code" from there.
- A new page will open with a list of files on the left side of the screen. Open the "theme.liquid"
-
Find where you have set the script for GTM in the "<head>". It should look similar to this:
- After you have located the script, copy its contents between "<script>" and "</script>" and paste them here:
<script> var iac=(document.cookie.match(/^(?:.*;)?\s*cookieconsent_preferences_disabled\s*=\s*([^;]+)(?:.*)?$/)||[,null])[1]; if(iac==null || (iac!=null&&iac.indexOf('analytics') == -1)){ } </script>
- When you are done the final result should look like this:
For better blocking of the Google Tag Manager follow the steps mentioned above and check the video:
In case of any questions, our FAQ page is available 24/7 or you contact us via chat or email.
If you still don’t use our GDPR/CCPA + Cookie Management app don’t think twice download it now.