Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
Forum Search
Google Site Search
 All Forums
 Technical
 PHP (Unix / Linux / Apache) versions
 GA4 Config when using Google Tag Manager
Author « Topic »  

ebp
Advanced Member

138 Posts

Posted - 04/11/2022 :  15:14:23  
If I added Google Analytics GA4 Configuration via Google Tag Manager, should I follow these instructions https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=114351 for adding the code to each page? Would that duplicate the efforts?

Vince
Administrator

42953 Posts

Posted - 04/12/2022 :  11:24:30  

ebp
Advanced Member

138 Posts

Posted - 04/12/2022 :  11:31:00  
ok, so I need to remove the Google Tag Manager tag and just use these instructions. Right?

Vince
Administrator

42953 Posts

Posted - 04/13/2022 :  09:23:19  

ebp
Advanced Member

138 Posts

Posted - 04/16/2022 :  15:22:06  
I've set up GA4 per instructions, but I am not seeing any conversions. I do see page_views, etc, but not a single conversion is registered.

I am double tagging so my old GA is still registering conversions correctly.

Please advise.

1818charlie
ECT Moderator

United Kingdom
1201 Posts

Posted - 04/16/2022 :  15:50:34  
Hi ebp

I posted this on the 13th regarding GA4. It's an article from search engine journal - could it be of any assistance?

https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=114741


Steve
Manchester UK

Make it as simple as possible, but not simpler.

Edited by - 1818charlie on 04/16/2022 15:51:15

Vince
Administrator

42953 Posts

Posted - 04/17/2022 :  04:10:18  
Hi Ebp
I had a look at one of your pages and it seems that the gtag is not defined. There are instructions here and you need to add the GA4 code to the head section.

https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=114351

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

ebp
Advanced Member

138 Posts

Posted - 04/17/2022 :  14:45:39  
Vince, I'm using incectstyle.php and I have the Measurement ID in my settings. GA4 shows it is getting traffic information but Thanks.php is not sending any conversions. When I check the source code I see this but not in GA4

<script>gtag("event","purchase",{ currency:"USD",value:25.95,shipping:5.5,tax:2.6,items:[{item_id:'AS-Assos-Chamois-Creme',item_name:'Assos Chamois Creme 200ml',index:1,item_brand:'Assos',item_category:'Cycling Apparel',price:25.95,quantity:1}]});</script>

What is worse, my Universal Analytics stopped collecting conversions as well. All other data is being collected. I see Realtime users on the site data is being sent to both GA4 and UA. Seems like all pages but the Thanks.php are working.

Let me know how I can reach out to you directly to get some help. Thank you.

Vince
Administrator

42953 Posts

Posted - 04/18/2022 :  04:50:30  
Hi Ebp
I think I see what the problem is and I've made a change to the incectstyle.php script to correct this, but a simple workaround for now would be to just add this to your includes.php file...

$GLOBALS['googletagid']='YOURGTAGID';

You have to make sure that the incectstyle.php script comes after the other include files.
If this doesn't sort it out (just refresh the page and do a View Source and search for "gtag()" in the header) then please send an email to vince AT ecommercetemplates DOT com

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

ebp
Advanced Member

138 Posts

Posted - 04/18/2022 :  05:55:03  
Almost there :)

I added the line to my includes.php and I finally see the gtag is at the top of the page. GA4 registered 'purchase' event but didn't show value. Maybe I need to wait in case there is a delay.

My Universal Analytics is still not registering the events, so I went to my admin settings and removed Global Site Tag. I placed a new order and now I see that my thanks.php is fireing correclty for UA with following code at the bottom.




<!-- #BeginEditable "footer" -->

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('require','ecommerce','ecommerce.js');
ga('ecommerce:addTransaction',{'id':'18762','affiliation':'','revenue':'25.95','shipping':'5.5','tax':'2.6'});
ga('ecommerce:addItem',{'id':'18762','name':'Assos Chamois Creme 200ml','sku':'AS-Assos-Chamois-Creme','category':'Cycling Apparel','price':'25.95','quantity':'1'});
ga('ecommerce:send');
</script>
<!-- #EndEditable -->


However, the page is not registering GA4 purchase event.

It seems that as soon as I put back the Global Site Tag in admin settings, the opposite happens.

Is there a way to double tag as suggested by Google so I can keep both of them for a while?

When Global Site Tag is added to Admin, here is how the UA code looks like on Thanks.php instead of sending ecom conversion.


<!-- #BeginEditable "footer" -->

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('require','ecommerce','ecommerce.js');
</script>
<!-- #EndEditable -->

Edited by - ebp on 04/18/2022 05:58:07

ebp
Advanced Member

138 Posts

Posted - 04/18/2022 :  06:23:20  
I have also gone to https://www.ecommercetemplates.com/phphelp/ecommplus/parameters.asp#analytics following these directions and tried replacing my current UA code but the result is the same. UA is not generating the ecommerce code portion.

Vince
Administrator

42953 Posts

Posted - 04/18/2022 :  06:38:17  
That code you posted is what I would expect if the googtletagid had not been set so now I'm not sure if this is from when you removed it or not. I didn't really think there was a need to display both sets of statistics so the code was such that if you were using the new GA4 analytics then the old wouldn't show. But I've changed that now in the v7.5 incthanks.php file so if you get a new copy of that (you can use the v7.5 incthanks.php even if you are on v7.4) then it should display both while we sort this out.

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

ebp
Advanced Member

138 Posts

Posted - 04/18/2022 :  07:19:13  
Vince, maybe I was too quick to download. incthanks.php shows March 4, 2022 stamp. Let me know when it's ready and I'll test again.

Vince
Administrator

42953 Posts

Posted - 04/18/2022 :  08:08:16  
Hi Ebp
quote:
incthanks.php shows March 4, 2022 stamp
That would be if you got the v7.4 updater but you need to get the v7.5 updater. If you are on v7.4 you can use the v7.5 version of incthanks.php

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

ebp
Advanced Member

138 Posts

Posted - 04/18/2022 :  08:53:24  
Thank you Vince. I got a fresh one and it's all working now.

I did find a bug in the IP blocking code since I was on checkout too many times.

Warning: Undefined variable $ppbits in ..../public_html/vsadmin/inc/inccart.php on line 4449

This happens when IP is blocked. Before the upgrade there was a user friendly message thrown.

Let me know if I should file that under a new topic.

Vince
Administrator

42953 Posts

Posted - 04/19/2022 :  03:21:02  
Hi Ebp
Yes, good point about the undefined variable and I've fixed it now. I think with earlier versions of PHP this would have gone unnoticed but now it causes an error so good to get it sorted. The change is in the updater in the inccart.php file.

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

Phil
ECT Moderator

United Kingdom
7740 Posts

Posted - 04/19/2022 :  03:40:26  
Hi Vince,
quote:

Hi Ebp
I think I see what the problem is and I've made a change to the incectstyle.php script to correct this, but a simple workaround for now would be to just add this to your includes.php file...

$GLOBALS['googletagid']='YOURGTAGID';


So rather than add incectstyle.php or the analytics code to every page I can just add that line to the includes.php and add the G4 ID in the main settings?



*Contact Us*
*Buy The PHP Capture Card Plugin*
*Rate Our Services/View Our Feedback*

Vince
Administrator

42953 Posts

Posted - 04/19/2022 :  08:09:22  
Hi Phil
You don't need to use incectstyle.php but if you don't you will need to add something like this to the head...

<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_GA4_TAGID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(\'js\', new Date());
gtag(\'config\', \'' . $GLOBALS['googletagid'] . '\');
</script>
}

The only reason for adding the tag id to the includes.php is because the incectstyle.php wasn't reading the tag id from the admin database column. Just setting it in the ECT Admin should be ok. And now I've fixed incectstyle.php to read from the database.

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.03 seconds. Snitz Forums 2000