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
 General
 Suggestions - NOT QUESTIONS
 Google Universal Analytics integration update
Author « Topic »  

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 10/28/2017 :  22:08:37  
Since 100% of Google Analytics properties have now been transferred across to Universal Analytics, I suggest it would be a good time to look at updating the Ecommerce Templates Parameters page explaining how to track orders using Google Analytics.

Please do add your comments to this suggestion as you like.

------------------------------------------------------------
(1) ga.js is now obsolete
Therefore, please correct me if I am wrong, but both these includes.php parameters are now also obsolete and have no effect whatsoever.

$googleanalyticsinfo=true; // Obsolete
$usegoogleasync=true; // Obsolete


------------------------------------------------------------
(2) What is written here applies to the thanks.php page only
Now the only includes.php parameter that you need is:

$usegoogleuniversal=true;

(2a) In your Google Analytics Account, this requires:
ADMIN ... VIEW ... Ecommerce Settings ... Enable E-commerce = ON

(2b) On the thanks.php page, in the <body>, this gathers all the Sales data and therefore must come first:

<?php include "vsadmin/inc/incthanks.php" ?>

(2c) And further down, somewhere before the closing </body> tag, you need this code which will pass the Sales data through to Google Universal Analytics:

<script>
(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('create', 'UA-XXXXX-Y', 'auto'); // Replace with your property ID
ga('send', 'pageview');
ga('require','ecommerce','ecommerce.js');
<?php print @$googleanalyticstrackorderinfo ?>

</script>


(2d) Google Tag Manager code cannot be used for this purpose.

(2e) You will not see the Sales data recorded in your Google Analytics Account until the following day.

------------------------------------------------------------
(3) Individual Product $Prices recorded as a sale should also include additional $ProductOption(s) ordered
What happens now is that incthanks.php passes on the $Price of each individual Product ordered. But the price for additional "Product Options" selected does not get added to the base Product Price.

In Google Analytics, look at CONVERSIONS ... E-commerce ... Product Performance ... and check out the "Product Revenue" column.

In my opinion the incthanks.php equation for each individual item sale should be:
$ProductPrice + $OptionsSelectedTotal = $Product Revenue

Total $Revenue recorded by Google Analytics is perfectly correct and does include Product Options ordered.

------------------------------------------------------------
(4) Add another Parameter to automatically integrate Ecommerce Templates with Google Adwords Campaign Reports
There have been Forum questions and discussion about how to intergrate ECT Shopping Cart sales performance into Google Adwords Campaign Reports:
https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=101352
https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=108588

Since use of Google Adwords is commonplace in online sales promotions, Ecommerce Templates software would be further enhanced if incthanks.php included this capability.

------------------------------------------------------------
(5) Google Analytics Page View Tracking code
For the website pages that you do wish to record visitor page view data (other than thanks.php), the Google Universal Analytics tracking javascript should be added near the top of the <head> tag and before any other script or CSS tags.

<!-- Google Analytics -->
<script>
(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','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto'); // Replace with your property ID
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->


The alternative async tracking snippet below adds support for preloading, which will provide a small performance boost on modern browsers, but can degrade to synchronous loading and execution on IE 9 and older mobile browsers that do not recognize the async script attribute.

<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); // Replace with your property ID
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->


My testing confirms that alternative script does pass visit data through to Google Analytics exactly the same. I doubt there are more than a handful of visitors using outdated browsers like IE 9 these days.

Either script is fine and will work even if located before the closing </body> tag. But near the top of the <head> tag is the recommended place, inside an Editable region so that you can pick and choose which pages you do (or do not) wish to track.

Google Tag Manager is another alternative you can use to record Page Views in Google Analytics.

Gary

Edited by - ITZAP on 10/28/2017 22:17:30

Andy
ECT Moderator

95440 Posts

Posted - 10/29/2017 :  03:07:20  
Hi Gary

Thanks for bringing that up. I'll do some testing and reading and report back.

Andy

Please feel free to review / rate our software

Phil
ECT Moderator

United Kingdom
7680 Posts

Posted - 10/29/2017 :  03:17:36  
Hi Gary,
quote:
In my opinion the incthanks.php equation for each individual item sale should be:
$ProductPrice + $OptionsSelectedTotal = $Product Revenue


Excellent suggestion Gary.



* Database Migrations and Conversions*
* ASP to PHP Cart Conversions*

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

Andy
ECT Moderator

95440 Posts

Posted - 10/30/2017 :  02:25:50  
I ran a test yesterday so could check the results today

I put this before the closing </body> tag on ALL pages

<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('create','UA-123456-1','auto');
ga('send','pageview');
ga('require','ecommerce','ecommerce.js');
<% print googleanalyticstrackorderinfo%>
</script>

and this in includes.asp

usegoogleuniversal=true

I checked that I was getting data by looking at thew Real Time feature whilst navigating the site and put an order though which shows up correctly in the Conversions > Ecommerce section of GA.

I know Google tell you to place any tracking code near the top of the page but personally I prefer not to potentially slow down page loading and have always placed it at the bottom anyway meaning you can happily use the above snippet on all pages for visit and sales tracking.

Andy

Please feel free to review / rate our software

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 10/30/2017 :  16:55:44  
Hi Andy,

Yes, I did mention that the analytics.js script actually "will work even if located before the closing </body> tag". And that it where it must be located on thanks.php

But to merely record Page Views (visits) on other pages, Ecommerce Templates users should be made aware that this portion of code is irrelevant, not necessary ...

ga('require','ecommerce','ecommerce.js');
<% print googleanalyticstrackorderinfo%>


The precise purpose of "async" is to delay script execution until the pageload is complete.
Therefore Google Analytics Page View Tracking code can be placed near the top of the <head> tag, like Google recommend, not a problem.
You do not need to be concerned that this will "potentially slow down page loading" at all.

Personally, I now prefer to use the "alternative async tracking snippet" you can see above in (5) which Google say "will provide a small performance boost on modern browsers".
Find more information here >>

Just sharing what I think are Google Analytics "best practices" here for the information of other ECT users.

Gary

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 12/20/2017 :  16:45:43  
Can I please bump this suggestion ??

(3) Individual Product $Prices recorded as a sale should also include additional $ProductOption(s) ordered

What happens now is that incthanks.php passes on the $Price of each individual Product ordered. But the price for additional "Product Options" selected does not get added to the base Product Price.

In Google Analytics, look at CONVERSIONS ... E-commerce ... Product Performance ... and check out the "Product Revenue" column.

I suggest that the incthanks.php Google Analytics equation for each individual item sale should be:

$ProductPrice + $OptionsSelectedTotal = $Product Revenue

Total $Revenue recorded by Google Analytics is perfectly correct and does include Product Options ordered.

Regards,

Gary

Vince
Administrator

42754 Posts

Posted - 07/05/2021 :  10:38:34  
We do normally try to be just a bit more responsive to customer requirements, but somehow this seems to have been overlooked till now. But finally, the options value has been added to the item price and has been added to the incthanks.asp/php script in the updater.

Apologies for the delay!

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