Google Analytics Ecommerce Tracking
Re: Google Analytics Ecommerce Tracking
jcgadgets wrote:Xsecrets wrote:Brocberry wrote:For those of us who send our customers to off-site to make payment, we need to give the gateway a page to send the customer back to once the transaction is complete... and then we tell GA which that page is I think. What page can we send the customer back to in OC for GA to recognise a complete transaction?
index.php?route=common/success most of the gateways will set this for you automatically.
Do you know if the PayPal Standard module has this set automatically?
Thank you,
Jared
yes it does.
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
- Xsecrets
- Posts: 5042
- Joined: Sat Oct 24, 2009 7:51 pm
- Location: FL US
Re: Google Analytics Ecommerce Tracking
jcgadgets wrote:I also wanted to see if what we have concluded here coincides with what others have come up in this thread?:
viewtopic.php?f=20&t=18926&hilit=ecomm
Or if perhaps we can get some ideas from there. Which modification method is "better"?
Thank you,
Jared
I think either one will work if you can figure them out since both seem to be very disjointed. Honestly google analytics with ecom support really should be put in the core. I mean seriously this is a shopping cart if you are going to bother providing analytics support in the core why wouldn't you add the ecommerce part since that should pretty much always be the main purpose of an opencart install.
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
- Xsecrets
- Posts: 5042
- Joined: Sat Oct 24, 2009 7:51 pm
- Location: FL US
Re: Google Analytics Ecommerce Tracking
Xsecrets wrote:...Honestly google analytics with ecom support really should be put in the core. I mean seriously this is a shopping cart if you are going to bother providing analytics support in the core why wouldn't you add the ecommerce part since that should pretty much always be the main purpose of an opencart install.
- Couldn't agree more! Couldn't have said it better. Very odd really, why it's not in the core. I wonder if it's planned for 1.5.0...
I guess I will just stick to this one, as this is the one I've already implemented. I'll watch and see if the next sale is captured (my site has only been live for just under a month, so the sales are coming in slowly as per nearly non-existent search rankings at the moment).
Thanks for the PayPal answer too

Thank you,
Jared
- jcgadgets
- Posts: 115
- Joined: Sun Oct 31, 2010 8:49 am
Re: Google Analytics Ecommerce Tracking
I'm trying to write a vQmod for this but can't seem to get it working. Has anyone had any luck implementing these code changes?
-

philbydevil - Posts: 828
- Joined: Thu Dec 02, 2010 9:20 pm
- Location: Sunshine Coast, Australia
Re: Google Analytics Ecommerce Tracking
I have edited my original post - it should work now. There were a couple of steps that were missing, follow steps 5 and 6 to provide access to order details on the checkout page.
Thanks
Justin
Thanks
Justin
Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN

Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN

- justinv
- Posts: 660
- Joined: Tue Oct 12, 2010 5:24 am
Re: Google Analytics Ecommerce Tracking
Awesome justinv! That seems to be working now. Will get the vQmod cleaned up (and add some instructions) and upload it shortly.
-

philbydevil - Posts: 828
- Joined: Thu Dec 02, 2010 9:20 pm
- Location: Sunshine Coast, Australia
Re: Google Analytics Ecommerce Tracking
vQmod uploaded.
Be sure to read the installation instructions (install.txt) prior to use or it won't work.
Thanks for the code justinv
Be sure to read the installation instructions (install.txt) prior to use or it won't work.
Thanks for the code justinv

- Attachments
-
vQmod - Google Analytics E-commerce.zip- (3.59 KiB) Downloaded 352 times
-

philbydevil - Posts: 828
- Joined: Thu Dec 02, 2010 9:20 pm
- Location: Sunshine Coast, Australia
Re: Google Analytics Ecommerce Tracking
According to Google, it seems that all products need SKUs to be tracked correctly. Not sure if this is correct or not.
EDIT: the SKU seems to be the product_id (from the DB) so they don't need to be set manually in Admin.
One thing that I am noticing with my test transactions is that in GA, under E-Commerce, "Categories" is reporting the "Product Categories" as the model number of product/s, not the actual category.
EDIT: the SKU seems to be the product_id (from the DB) so they don't need to be set manually in Admin.
One thing that I am noticing with my test transactions is that in GA, under E-Commerce, "Categories" is reporting the "Product Categories" as the model number of product/s, not the actual category.
-

philbydevil - Posts: 828
- Joined: Thu Dec 02, 2010 9:20 pm
- Location: Sunshine Coast, Australia
Re: Google Analytics Ecommerce Tracking
Hi all,
I just wanted to report that, unfortunately, this does not seem to be working for me
I'm quite certain I implemented everything correctly, as I asked questions on the things I was not 100% certain about. I got a sale a few days ago, and just checked Google Analytics. Unfortunately, it was not reported there.
I'm going to give that other thread I mentioned a shot and see what happens.
Thank you!
Jared
I just wanted to report that, unfortunately, this does not seem to be working for me
I'm quite certain I implemented everything correctly, as I asked questions on the things I was not 100% certain about. I got a sale a few days ago, and just checked Google Analytics. Unfortunately, it was not reported there.I'm going to give that other thread I mentioned a shot and see what happens.
Thank you!
Jared
- jcgadgets
- Posts: 115
- Joined: Sun Oct 31, 2010 8:49 am
Re: Google Analytics Ecommerce Tracking
Common problem is javascript errors on your page - if you have a js error, your analytics will not fire.
Create a free product and do some test purchases on it on your site, you should be able to see those come through or notice if there are js errors on the page using web developer toolbar in FF or the little icon bottom left in IE.
Create a free product and do some test purchases on it on your site, you should be able to see those come through or notice if there are js errors on the page using web developer toolbar in FF or the little icon bottom left in IE.
Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN

Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN

- justinv
- Posts: 660
- Joined: Tue Oct 12, 2010 5:24 am
Re: Google Analytics Ecommerce Tracking
Hey thanks!
I will try that out!
Thank you,
Jared
I will try that out!
Thank you,
Jared
- jcgadgets
- Posts: 115
- Joined: Sun Oct 31, 2010 8:49 am
Re: Google Analytics Ecommerce Tracking
Xsecrets wrote:Brocberry wrote:For those of us who send our customers off-site to make payment, we need to give the gateway a page to send the customer back to once the transaction is complete... and then we tell GA which that page is I think. What page can we send the customer back to in OC for GA to recognise a complete transaction?
index.php?route=common/success most of the gateways will set this for you automatically.
Thanks but I'm not sure I understand... that url, is that the real url for opencart and as it happens the same url for most other carts?
- Brocberry
- Posts: 47
- Joined: Mon May 31, 2010 7:31 pm
- Location: England
Re: Google Analytics Ecommerce Tracking
Hi Justinv, everyone
Two questions, if I may:
(1) Does this require the GA module to be installed (if GA code has been added to header.tpl manually)?
(2) Does the async GA snippet go before or after "<?php echo $google_analytics; ?>"?
NB: I have been tracking OpenCart via GA for some time (using the include method in the body tag) and have since switched to the async GA method, placing the code (below) in the header.tpl. I have never installed the GA module supplied with OpenCart's, however -I added the code myself. I was wondering then, if this would work for me or if someone could explain what the '<?php echo $google_analytics; ?>' code does?
Excerpt from my header.tpl (account number removed):
Thanks in advance, all the best!
Gary
Two questions, if I may:
(1) Does this require the GA module to be installed (if GA code has been added to header.tpl manually)?
(2) Does the async GA snippet go before or after "<?php echo $google_analytics; ?>"?
NB: I have been tracking OpenCart via GA for some time (using the include method in the body tag) and have since switched to the async GA method, placing the code (below) in the header.tpl. I have never installed the GA module supplied with OpenCart's, however -I added the code myself. I was wondering then, if this would work for me or if someone could explain what the '<?php echo $google_analytics; ?>' code does?
Excerpt from my header.tpl (account number removed):
- Code: Select all
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-xx']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php echo $google_analytics; ?>
</head>
Thanks in advance, all the best!
Gary
- traceofwind
- Posts: 82
- Joined: Thu Jul 01, 2010 10:37 pm
Re: Google Analytics Ecommerce Tracking
Hi Gary,
The GA module gives you a text area in your admin where you can put your GA code from Google.
The echo $google_analytics; code puts whatever you put in admin onto your page. So putting your async GA code directly in the header.tpl is the same as enabling the GA module and putting the async GA code into your admin text area. Apart from by default, the echo $google_analytics; is in the footer, so on a default install it would go before the closing </body> tag.
In summary you should do one or the other - either enable the GA module, or paste your code directly into your header. Enabling the module would be preferable, as it's better to play by the rules.
The GA module gives you a text area in your admin where you can put your GA code from Google.
The echo $google_analytics; code puts whatever you put in admin onto your page. So putting your async GA code directly in the header.tpl is the same as enabling the GA module and putting the async GA code into your admin text area. Apart from by default, the echo $google_analytics; is in the footer, so on a default install it would go before the closing </body> tag.
In summary you should do one or the other - either enable the GA module, or paste your code directly into your header. Enabling the module would be preferable, as it's better to play by the rules.
Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN

Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN

- justinv
- Posts: 660
- Joined: Tue Oct 12, 2010 5:24 am
Re: Google Analytics Ecommerce Tracking
Hi,
I can't quite get this working. I have updated the relevant pages (1) footer.php, (2) header.php, (3) success.php, (4) order.php, (5) footer.tpl, (6) header.tpl and (7) success.tpl -but to no avail. Specifically, the Google Ecommerce tracking script does not appear in the source code upon Order Confirmation (success) page.
I am testing my site using 'Cash on delivery' payment method -that shouldn't cause any problems -should it?
Additionally, I would rather not use the vqMod as my files are already modified. At this point I'd appreciate any advice -I can't see what is wrong. My only clue is that Dreamweaver tells me there is a problem with the code syntax on the following lines:
Any ideas?
Best regards,
Gary
PS,
Justinv -you may want to add to the first post, that the success.tpl code should be added before the '<?php echo $footer; ?>' code. Currently it doesn't specify where to insert the code.
EDIT-
Justin, your code for success.tpl, may I ask why you used this Asynchronous code in the body and not the header, or why did you not use the 'Traditional' code as per Google's own Ecommerce example code? It is my understanding that Async code (that you have kindly provided) is intended for the <head></head> tags -not to be included in the <body></body> tags -as the Traditional code is.
I can't quite get this working. I have updated the relevant pages (1) footer.php, (2) header.php, (3) success.php, (4) order.php, (5) footer.tpl, (6) header.tpl and (7) success.tpl -but to no avail. Specifically, the Google Ecommerce tracking script does not appear in the source code upon Order Confirmation (success) page.
I am testing my site using 'Cash on delivery' payment method -that shouldn't cause any problems -should it?
Additionally, I would rather not use the vqMod as my files are already modified. At this point I'd appreciate any advice -I can't see what is wrong. My only clue is that Dreamweaver tells me there is a problem with the code syntax on the following lines:
- Code: Select all
'<?php echo $orderDetails['order_id']; ?>',
...
'<?php echo $orderDetails['total']; ?>',
Any ideas?
Best regards,
Gary
PS,
Justinv -you may want to add to the first post, that the success.tpl code should be added before the '<?php echo $footer; ?>' code. Currently it doesn't specify where to insert the code.
EDIT-
Justin, your code for success.tpl, may I ask why you used this Asynchronous code in the body and not the header, or why did you not use the 'Traditional' code as per Google's own Ecommerce example code? It is my understanding that Async code (that you have kindly provided) is intended for the <head></head> tags -not to be included in the <body></body> tags -as the Traditional code is.
- traceofwind
- Posts: 82
- Joined: Thu Jul 01, 2010 10:37 pm
Re: Google Analytics Ecommerce Tracking
Shouldn't your code closing tag:
be instead
I'm also not seeing the ecom tracking code on my success page in the page source... almost like it didn't recognize the <?php if(isset($orderDetails) && isset($orderProducts)) { ?> statement, but I have confirmed the appropriate code to be in my success.php file before $this->cart->clear();
Please advise.
- Code: Select all
<?php foreach($orderProducts as $product) { ?>
_gaq.push(['_addItem',
"<?php echo $product['order_id']; ?>",
"<?php echo $product['product_id']; ?>",
<?php echo json_encode($product['name']); ?>,
"<?php echo $product['model']; ?>",
"<?php echo $product['price']+($product['price']*$product['tax']/100); ?>",
"<?php echo $product['quantity']; ?>"
]);
<? } ?>
be instead
- Code: Select all
<?php } ?>
I'm also not seeing the ecom tracking code on my success page in the page source... almost like it didn't recognize the <?php if(isset($orderDetails) && isset($orderProducts)) { ?> statement, but I have confirmed the appropriate code to be in my success.php file before $this->cart->clear();
Please advise.
-

stonehinged - Posts: 113
- Joined: Wed Aug 18, 2010 1:10 am
- Location: US
Re: Google Analytics Ecommerce Tracking
Similar to Stonehinged,
I am still experiencing the same issues: no e-commerce tracking code on the success page nor results in Google Analytics.
Also interesting what Stonehinged pointed regarding the closing tag, can anyone else confirm?
All the best
I am still experiencing the same issues: no e-commerce tracking code on the success page nor results in Google Analytics.
Also interesting what Stonehinged pointed regarding the closing tag, can anyone else confirm?
All the best
- traceofwind
- Posts: 82
- Joined: Thu Jul 01, 2010 10:37 pm
Re: Google Analytics Ecommerce Tracking
Unfortunately, it didn't help with the end result and achieving the data expected. I can't see the Google Ecom tracking at all in page source, but even stranger... no apparent errors in OC admin. It's like the "if" statement is coming back "null" so no code shows up. I may try an "else" statement to see if that content will display for me. If that does, that should fairly well conclude there's an issue with the "if" statement or code it's referring to on the success.php file.
-

stonehinged - Posts: 113
- Joined: Wed Aug 18, 2010 1:10 am
- Location: US
Re: Google Analytics Ecommerce Tracking
So I can confirm with an "else" statement, the "else" condition displays... maybe this helps us debug?
-

stonehinged - Posts: 113
- Joined: Wed Aug 18, 2010 1:10 am
- Location: US
Re: Google Analytics Ecommerce Tracking
Hi Stonehinged,
Nice idea, I had suspected the IF statement but hadn't thought of adding an ELSE statement to help us debug, kudos! I will try some debugging myself on this tangent and report back.
PS, did you try the VQ Mod or did you install manually?
Nice idea, I had suspected the IF statement but hadn't thought of adding an ELSE statement to help us debug, kudos! I will try some debugging myself on this tangent and report back.
PS, did you try the VQ Mod or did you install manually?
- traceofwind
- Posts: 82
- Joined: Thu Jul 01, 2010 10:37 pm
Who is online
Users browsing this forum: No registered users and 10 guests


cmd-f, cmd-c, cmd-v, cmd-z + vQmod.










