Liquid, JavaScript, themes, sales channels
This is by far the most frustrating issue I've run into with Shopify. I'm trying to optimize a client's site speed by wrapping up all their tracking codes into Google Tag Manager to reduce the total number of outgoing requests. I removed all hardcoded tracking pixels from theme.liquid and placed them in GTM, went through ALL the apps and sales channels and disconnected from accounts, but there are still extra codes being loaded by Trekkie.
I'm using the Shopify Facebook and Google Analytics integrations as recommended, so those are not represented in GTM. Even so, it's still somehow loading 2 Google Analytics, 2 Google Ads and 2 Facebook pixels.
As you can see in the source code, there are 2 facebook pixel ids contained within the Trekkie object, but how is this possible when there's only one place to add this information?
If I remove the facebook pixel id from this screen (Themes > Preferences), then the first pixel will not load, only the second unwanted pixel loads. The same issue persists for Google Analytics and Google Ads, except I cannot see multiple account ids in the source code, I can only see this in the network tab of DevTools and in the Google Tag Assistant.
I would typically assume that these codes must be in the theme code somewhere or an app or something, except I can actually see with DevTools that the code is being called by Trekkie.
This is driving me absolutely crazy and I've already spent lots of time trying to make what I thought should be a simple optimization. If anyone can help with this issue I'd be hugely appreciative.
Thanks!
Solved! Go to the solution
This is an accepted solution.
Hi @plasmablobs , I actually found a solution, hacky though it may be. Comment out the first "content_for_header" instance, and then use a Liquid replace string filter to remove the specific pixel id and replace it with an empty string. It looks like this.
{% comment %}{{ content_for_header }}{% endcomment %}
{{ content_for_header | replace: '12345', '' }}
Inspect the source code on your site to find the pixel id you don't want and use that instead of '12345'.
Here's the link that helped me find this answer: https://community.shopify.com/c/Shopify-Discussion/Shopify-Trekkie/td-p/358102 (scroll down to Subhranil's answer)
It's so frustrating that 3rd parties can bog down stores with unwanted code like this. I wish Shopify would give us a solution for this.
User | RANK |
---|---|
33 | |
26 | |
18 | |
9 | |
9 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023