Google Analytics code not showing in source code

Dov
Tourist
4 0 2

Hello,

I am a new Shopify user with a new site, I have just been through the rigmoral of trying to add G4 stream tracking code and realising that we can't use G- and need UA- instead which I have ready now.

I entered the standard GA code which looks like this

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-183942995-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-183942995-1');
</script>

In the Online store preferences bit.

But when I inspect code on the site the only place the UA is mentioned is on a line called  trekkie.load

The tracking code is not there and obviously not recording data in analytics.

Can anyone see what is wrong with just this information?

https://www.dukesvalley.co.uk/

Many thanks for any help.

Dov

 

Anormaluser1
New Member
1 0 0

Same Issue here!!

0 Likes
Dov
Tourist
4 0 2

Update,

adding the gtag analytics code as its shown in analytics is now coming up in the source code, however it is stripping the gtag js:

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxx-1"></script>

Tag assistant is not showing anything installed.

This is how it looks in the source code:

<script>window.ShopifyAnalytics.merchantGoogleAnalytics = function() {
  <!-- Global site tag (gtag.js) - Google Analytics -->


  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-xxxxxxx-1');
};</script>

 

0 Likes
HymnZ
Pathfinder
341 1 36

@Dov where are you adding this code snippet in Shopify?

I make apps and can help you in setting up payment gateways..
0 Likes
Dov
Tourist
4 0 2

@HymnZ thanks for asking, I was trying to add it in the Additional Google Analytics JavaScript section in preferences because just adding the UA wasn't working.

We have tried adding the gtag code to the header file instead, Analytics worked fine but it wasn't recording transactions. 

I removed it from the header file thinking that keeping the tracking within the admin was the only way to tie in with shopify conversions.

I have now installed the old fashioned analytics.js in the Additional Google Analytics JavaScript section as at least that works but again not recording conversions.

 

I am now thinking that adding the gtag tracking code to the header file then adding additional code to the Google Analytics JavaScript section to pass transaction data through to analytics is the answer? I have been researching but can't find anything definitive. https://www.dukesvalley.co.uk/

Thanks for any advice.

 

0 Likes
HymnZ
Pathfinder
341 1 36

I don't think Shopify supports GA4 eCommerce yet. You're better off manually adding GA4 in the header and on the Checkout page and track GA4 events manually.

I make apps and can help you in setting up payment gateways..
0 Likes
Dov
Tourist
4 0 2

Thanks for your reply, yes I know i mistakenly tried to set up a GA4 stream to start with.

It's the GA3 tracking code I'm trying to implement that looks like this but when I add it to the header the transactions aren't recorded and when I add it to the Shopify admin it strips the gtag js

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-183942995-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-183942995-1');
</script>

0 Likes
DevQeeBoo
New Member
3 0 0

Hi Dov!

Have you found a solution?

Thanks in advance

0 Likes