Personalized checkout and custom promotions with Shopify Scripts
There's currently an add-to-cart tracking issue on Google Analytics
A previous developer may have been the one to input that code. I'm unaware why the additional code has been placed.
Can i remove the additional GA code existing on my site to see if it is causing the add-to-cart tracking issue?
My site is Shopify Plus.
The code is:
var pathname = location.pathname;
if (pathname.indexOf('/checkouts/') > -1){
(function(d, w) {
if(document.querySelector('[data-step="shipping_method"]') !== null){
var price = document.getElementsByClassName('payment-due__price');
var paymentDue = parseInt(price[0].attributes["data-checkout-payment-due-target"].value);
var i = document.getElementsByClassName("section--shipping-method")[0],
fs = i.querySelector('[data-shipping-method*="shopify-Standard%20Free%20Shipping"]'),
t = fs.parentNode,
ss = i.querySelector('[data-shipping-method*="shopify-Standard%20Shipping"]'),
n = ss.parentNode,
el;
if (paymentDue >= 500000){
n.remove();
el = t.getElementsByClassName('input-radio')[0];
} else {
t.remove();
el = n.getElementsByClassName('input-radio')[0];
}
if (el.onclick) {
el.onclick();
} else if (el.click) {
el.click();
}
}
var s = document.createElement("SCRIPT");
s.src='https://cdn.shopify.com/s/files/1/0063/4932/4335/t/159/assets/xpanse-shopify-address-validator-1.1.2.js?v=06042020';
s.type = 'text/javascript';
s.async = 1;
d.body.appendChild(s);
})(document, window);
}
Help me check on that. Thanks
Solved! Go to the solution
This is an accepted solution.
Feel free to drop us an email at info@whitewatersolutions.com. We can take a look at the site for you.
Keep well.
WhiteWater Web
Hi there - yes this can be safely removed; depending on what you want to do exactly, there may be better ways to do this using GTM, checkout.liquid customizations, etc.
Cheers.
WhiteWater Web
Thank you for your support and i have more question.
It seems to be the result of Google Analytics JavaScript is permanently disabled on Shopify beginning March 1st then it can make other bug but i don't know what bug did happen then i want to move it to other way what can make it works as in past.
What code is mean added on my site's Google Analytics above? How can i move it to checkout.liquid?
I'm new Shopify's member.
Thanks
This is an accepted solution.
Feel free to drop us an email at info@whitewatersolutions.com. We can take a look at the site for you.
Keep well.
WhiteWater Web
User | RANK |
---|---|
4 | |
3 | |
2 | |
1 | |
1 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023