Clean up Hardcoded Pixel Codes

Learn about the issues with hard-coded pixels and how you can clean them to prevent double-tracking issues with your conversions.

Before you start setting up Analyzify, we strongly recommend cleaning up the hardcoded pixel codes, in addition to the Google Tag Manager container code from your theme files & additional scripts.

Some pixels/codes that should be cleaned up:

  • GTM container snippet,
  • Data layers that are added earlier,
  • Google Analytics 4 codes,
  • Google Ads conversion pixels.

Please read this article with attention, understand the cases and learn how you should take the action.

Understanding the Cases

You do NOT want to have the following scenarios:

Hardcoding the same tag multiple times:

You shouldn’t have the same pixel twice on your theme files. Examples could be:

  • GTM container being added twice to the “theme.liquid” file,
  • GTM container being added to the “theme.liquid” file and getting rendered by another GTM container through a snippet (usually apps do this).

GTM container code is an example here. It could also be the Global Site Tag or another tag.

Hardcoding a pixel that you are already using through GTM:

If you have a tag deployed through GTM or another app, you don’t have to hard code the same tag as a pixel. As an example: If you have GTM installed, and run GA4 through GTM, you should remove the GA4 pixels from your theme files to prevent double tracking.

The same goes for Google Ads conversion tracking. If you are using conversion tracking through GTM, you should remove the pixels from the “Additional Scripts” page. Just make sure that you are removing the pixel that has the exact same conversion ID and label.

Hardcoding a pixel that you have already integrated with Shopify’s native integration:

If you are using Shopify’s native Google Analytics (UA: Universal Analytics) integration, you should not have the UA tracking codes added to your theme files additionally, because Shopify already does that.

The same goes for Facebook Pixel: If you are using the official Facebook app, and it has connected correctly with your Facebook Pixel, then you should remove the Facebook Pixel codes from your theme files.

Cleaning Up the Theme Files

Even though it is a relatively easy and straightforward process, you should definitely take a backup of your current theme before you implement any of these changes.

Removing the GTM Codes

We recommend that you remove the GTM codes from your theme files before you start setting up Analyzify so as not to cause any double tracking issues. Analyzify will already add them in the best possible way.

  • “Theme.Liquid” file:

Go to your Shopify Admin > Online Store > Themes. Choose the “Active theme” and find the “theme.liquid” file.You should search for “GTM-” and it will lead you to the section where your GTM code is inserted. You can just delete that, but make sure you start deleting from “<!-- Google Tag Manager -->" and finish with “<!-- End Google Tag Manager -->".

Clean up GTM container codes on the Shopify theme.liquid
Clean up GTM container codes on the Shopify theme.liquid
  • Additional snippets: Search “render” and “include” on your “theme.liquid” file, and this will show you the snippets that are included on the file.
Find additional snippets - 1
Find additional snippets - 1

You might see a little arrow icon next to the snippet name: When you click on it, it will show you the snippet. Alternatively, you can search for the snippet name in the left search bar.

Find additional snippets - 2
Find additional snippets - 2
  • Other apps: You might have some apps that inject GTM or other pixels into your store, so make sure to check all your related apps.

Removing GA4 Codes

The code for Google Analytics 4 has most likely been hardcoded into your theme because that used to be the typical method for setting up GA4 on Shopify.

You should follow the same steps mentioned above, but this time you will be looking for a code that starts with “G-”.

GA4 Code block on Shopify
GA4 Code block on Shopify

Make sure to remove this pixel if you are using GA4 through GTM or setting up Analyzify.

Removing UA Codes

Most stores use Shopify’s native integration for their Universal Analytics setup. Therefore, you neither need nor should have these pixels hardcoded on your theme files.

You should again follow the same steps mentioned above, but this time you will be looking for a code that starts with “UA-”.

UA code block on Shopify
UA code block on Shopify

Make sure to remove this pixel if you are using UA through Shopify’s native integration or GTM with Analyzify.

Cleaning Up the Additional Scripts

You might have some pixels on your Checkout > Order Processing > Additional Scripts. You should remove the codes from there in case you plan to use Analyzify’s GTM container for the same reason.

The pixels that should be cleaned:

  • GA4 pixel,
  • Google Ads conversion pixel (if the conversion ID/label is the same with Analyzify setup),
  • GTM container (Analyzify will already inject the GTM container here).

You can get our support team’s help if you have any questions!

Table Of Contents