Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: add-to-cart tracking issue on Google Analytics

Solved

add-to-cart tracking issue on Google Analytics

Sapota
Shopify Partner
2 0 0

There's currently an add-to-cart tracking issue on Google Analytics

bb.png

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

Accepted Solution (1)
WhiteWater_Web
Shopify Partner
462 17 42

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

A certified Shopify Partner and Expert, WhiteWater Web (WWW) is a premium digital solutions company specializing in advanced Shopify Dev, Usability/Design, and Online Strategy. WWW has been working with the Shopify platform since 2006.
info@whitewatersolutions.com

View solution in original post

Replies 3 (3)

WhiteWater_Web
Shopify Partner
462 17 42

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

A certified Shopify Partner and Expert, WhiteWater Web (WWW) is a premium digital solutions company specializing in advanced Shopify Dev, Usability/Design, and Online Strategy. WWW has been working with the Shopify platform since 2006.
info@whitewatersolutions.com
Sapota
Shopify Partner
2 0 0

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

WhiteWater_Web
Shopify Partner
462 17 42

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

A certified Shopify Partner and Expert, WhiteWater Web (WWW) is a premium digital solutions company specializing in advanced Shopify Dev, Usability/Design, and Online Strategy. WWW has been working with the Shopify platform since 2006.
info@whitewatersolutions.com