Forums / General Questions / Google Ecommerce Tracking

Google Ecommerce Tracking

Views: 37,009

Results 61 to 80 of 108
27 Jul 2017, 5:59 PM
#61
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Google Ecommerce Tracking

bonheddwr:

PS, I don't know if this could be the issue, but we use worldpay and paypal for payments.
The URL people arrive at after paying for an order using Worldpay is similar to this. Even though it is our website that appears, the URL is actually secure.worldpay.com . Could this be an issue as to why the orders aren't being recorded?

I'll probably follow this (and your previous post) up with more detail sometime tomorrow (it is after 3am here), but meanwhile I will say that this is a possibility... but only because I know nothing about the worldpay module or how it interacts with the "normal" zencart checkout process.

The ec module & Paypal work fine together, but I'm thinking that if it is only some of the transactions not being recorded could it be that those are the ones being paid for via worldpay?

If that is the case it would imply that the worldpay module is bypassing the code that contains the checkout_success notifier that trigger the ec module to send the data to google... or perhaps it is bypassing a pre checkout notifier that the module uses to obtain the data to be sent.

... or perhaps not.

It would/could be really helpful if you could confirm (or refute) this possibility though... IOW, I'm asking is it the PP transactions being recorded and the worldpay ones not? or is it more random than that?

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

27 Jul 2017, 6:18 PM
#62
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Google Ecommerce Tracking

Note: on success, a payment module should redirect to the checkout_success page. This is true even for hacky integrations like the 3rd-party worldpay contribution.
It's not uncommon for some offsite payment gateways to come back to the store with "their" URL showing in the browser, until the module moves from checkout_process (invisibly) to checkout_success. In other words, it could be the Worldpay module that's not doing all it needs to do in order to be compatible with how other plugins expect things to work post-checkout.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 Jul 2017, 11:05 AM
#63
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Ecommerce Tracking

bonheddwr:

my Google Analytics layout looks slightly different to yours,

Does it look more like my screenshot now that you have the "Enabled Enhanced Ecommerce Reporting" set to 'On'?

Anyway, I think we could be on the right track with the assumption that it could be the worldpay module. I've just downloaded this module and after a quick look at the files I noted that it has its own 'checkout_success' php file, but rather than using the default/standard zencart notifier (NOTIFY_HEADER_START_CHECKOUT_SUCCESS) it has its own one defined,

$zco_notifier->notify('NOTIFY_HEADER_START_WP_CHECKOUT_SUCCESS');

This means that the ec module is never going to be notified about a successful checkout, therefore, no analytics sales data will be recorded.

Although there are several methods that can be used to rectify the problem I think the 'safest' one one would be to load the file
/includes/classes/observers/class.ec_analytics.php into a text editor.

Find the line that reads

'NOTIFY_HEADER_START_CHECKOUT_SUCCESS',

Then add a line just below it that reads
'NOTIFY_HEADER_START_WP_CHECKOUT_SUCCESS',

Then scroll down and find the line that reads
case 'NOTIFY_HEADER_START_CHECKOUT_SUCCESS' ;

Then add another line just below this that reads
case 'NOTIFY_HEADER_START_WP_CHECKOUT_SUCCESS' ;

Now, having said that, the easiest solution would probably be to
load the file /includes/modules/wp_checkout_success.php into a text editor then either change the line that reads
$zco_notifier->notify('NOTIFY_HEADER_START_WP_CHECKOUT_SUCCESS');
to
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SUCCESS');

OR, simply add this change as a new line/notifier, so the code reads

$zco_notifier->notify('NOTIFY_HEADER_START_WP_CHECKOUT_SUCCESS');
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SUCCESS');

Either of these options may have unexpected side effects though. I've not delved deep enough into the code to may a valid judgement call here.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

28 Jul 2017, 12:34 PM
#64
bonheddwr avatar

bonheddwr

Zen Follower

Join Date:
Jun 2007
Location:
Cymru
Posts:
124
Plugin Contributions:
0

Re: Google Ecommerce Tracking

Thank you very much for your help. I've tried the option below. I was going to try your 1st option, but I couldn't find the following line in the file ```
case 'NOTIFY_HEADER_START_CHECKOUT_SUCCESS' ;


> **RodG:**
>
> OR, simply add this change as a new line/notifier, so the code reads 
> 
> $zco_notifier->notify('NOTIFY_HEADER_START_WP_CHECKOUT_SUCCESS');
> $zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SUCCESS');

Unfortunately it doesn't seem that ours is a worldpay only issue. Please see the following image. In the last 6 days only two orders have been recorded in analytics. Both are Paypal ones, but as you will see there are other paypal ones that have not been recorded.

Attachment 17187
29 Jul 2017, 5:58 AM
#65
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Ecommerce Tracking

bonheddwr:

Thank you very much for your help. I've tried the option below. I was going to try your 1st option, but I couldn't find the following line in the file ```
case 'NOTIFY_HEADER_START_CHECKOUT_SUCCESS' ;


There would only be one line of code like this (with a 'case' and a ' NOTIFY_HEADER_START_CHECKOUT_SUCCESS' - so that would've been (is) the right place to add the new line 

> **bonheddwr:**
>
> Unfortunately it doesn't seem that ours is a worldpay only issue. Please see the following image. In the last 6 days only two orders have been recorded in analytics. Both are Paypal ones, but as you will see there are other paypal ones that have not been recorded.

You are correct, in that it no longer seems to be a WorldPay only issue - But, thanks to your screenshot, I'm now thinking that you actually have two different issues. 

If this were a systemic problem,  the fact than 2 of the 6 PayPal transactions were recorded, would suggest that there *should* also have been ~4 of the 12 worldpay transactions recorded - You have *none*.  So, I think I/we are still on the right path with these, and you should continue with this approach until you can at least get *some* of  the Worldpay ones to show (even if it is just one). 

The next step would then be to try to figure out why only *some* transactions are being recorded (regardless of payment method). 

The fact that there are more transactions that fail to be recorded than those that succeed could be a clue in itself - Now, I could be *way* off the mark here -  but I couldn't help but notice *most* of your product names *appear* to be like 
"name dash number"  

*Perhaps* the 'dash' is a minus symbol and *something* (the ec module or the Google analytics server) is seeing this as being a mathematical formula rather than as a text string?   
Another *perhaps* is that the 'dash' isn't always what it appears - and is possibly some weird UTF8 character that needs to be 'escaped'.  

The point/thing here is that if we only look at the PayPal transactions - Two of the six worked -  What is it about these two that is *different* from the others -  Could it be that these two just happen to be products with the 'dash number' in their names?  

Can you see anything else that would differentiate the 2 successful recordings from the 4 failed ones? 

Anyway, I still think the 1st step is to get the worldpay transactions to be recorded, because it look like this is how most of your customers are paying, and when this is working we will then have a much bigger data pool in which we can try to find the 'some do, dome don't) differences.    

Basically, I feel that you currently have two unrelated problems. 

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

15 Aug 2017, 2:44 PM
#66
bonheddwr avatar

bonheddwr

Zen Follower

Join Date:
Jun 2007
Location:
Cymru
Posts:
124
Plugin Contributions:
0

Re: Google Ecommerce Tracking

Thanks for all of your help above Rod. You were correct, we had two unrelated issue.

1, For some reason your easy to install plugin didn't work for us. It may be because oure site has been modified quite a bit. Some Paypal transactions were showing in Google Analytics, but not all, and I couldn't fugure out why! I have now installed a different plugin (Easy Google Analytics). It was harder to install than yours, but it seems to be working and recording all paypal transactions.

2, Worldpay!! I've done quite a bit of research, and from what I have found out Worldpay isn't compatible with Google analytics, no matter what plugin is used, or how you install the google analytics code on your site. This makes no sense whatsoever to me, but it seems that currently it's impossible to track trasnactions via Google Analytics if using Worldpay. :/ More info here - https://adigital.agency/blog/google-ecommerce-tracking-with-the-worldpay-payment-gateway

Thanks again Rod for your help.

15 Aug 2017, 3:32 PM
#67
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Ecommerce Tracking

  1. You claim that the ec_commerce module didn't work, yet you showed screenshots to show that it did, at least some of the time, so that would negate your theory about site modification would be the cause.

  2. The blogpost about worldpay is utter BS. Well, it may be true for some systems/modules, but it certainly isn't going to be true for zencart and the ec_commerce module. The ec_commerce module stores the needed data into a session variable before the payment module(s) come into play, and as long as the checkout success notifier is triggered after payment has been made the prestored session data will be sent to google analytics. There is no way that worldpay can prevent this ... you just need to add the $zco notifier into the code that is loaded when worldpay returns back to zencart.

IOW, you do still have two separate problems... one which you have mitigated with a different analytics module (I would have preferred you worked with me on this in order to help others that may have the same issue). The other issue (wordpay) you have chosen to just ignore because some blogpost that has nothing to do with zencart tells you that it doesnt work. I find that a little sad considering that your screenshot shows that most of your sales are paid for with worldpay.

Oh well..

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

15 Aug 2017, 3:42 PM
#68
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Ecommerce Tracking

Worldpay ec tracking Can be done... one solution is mentioned here ....https://stackoverflow.com/questions/5903518/using-google-analytics-with-worldpay ..... but you dont need the "thank you" page because the zencart notifier (when added/triggered) will call the ec_commerce script to complete the tracking/logging.

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

15 Aug 2017, 3:50 PM
#69
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Google Ecommerce Tracking

ps. I think you must have found the only page/blog on the internet that claims worldpay cant be tracked with google analytics. I easily found that this has been "solved" by numerous ecommerce systems. :)

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

27 Oct 2017, 10:17 PM
#70
jpietrowiak avatar

jpietrowiak

Zen Follower

Join Date:
May 2009
Posts:
122
Plugin Contributions:
0

Re: Google Ecommerce Tracking

I've been using easy analytics and adwords in zencart 1.5.4. Lots of warnings with this module about running additional analytics code and I understand why about messing up data (been there done that trying to get done with easy analytics - no success).

Looking to use adwords and tag manager and get setup right.
Anyone successfully implemented this? working on this? or should I not attempt this with this module due to its design?

(I am fully aware it will greatly mess up your data if not done correctly)

Thanks for any help in setting this up.

1 Nov 2017, 8:41 PM
#71
jpietrowiak avatar

jpietrowiak

Zen Follower

Join Date:
May 2009
Posts:
122
Plugin Contributions:
0

Re: Google Ecommerce Tracking

Successfully installed module however the Brand: is not passing to the code in the Successful checkout page. I see the brand displayed on all prior pages before checkout is complete. Any ideas as to why this value would not be passed? See below code that was on the checkout page. It appears everything else passes ok. Not sure if this is a bug with the module or not? I tried it loaded in two other theme templates and still occurs.

ga('require', 'ec');
ga('require', 'displayfeatures');
ga('send', 'event', 'Checkout Success' , 'Order#46926','customerID#17551' );
ga('ec:setAction', 'purchase', { 'id': '46926','affiliation': 'purchaseorder', 'revenue': '67.58', 'tax': '3.58','shipping': '0.00','coupon': 'n/a', 'dimension1': 'customerID#17551' });
ga('ec:addProduct', {   'id': '208', 'name': 'RS232 Cable', 'brand': 'n/a', 'category': 'Cables', 'variant': 'n/a', 'price':  '67.58', 'quantity': '1', 'coupon': 'n/a', 'position': '0' } );
ga('send', 'pageview');
2 Nov 2017, 12:07 AM
#72
jpietrowiak avatar

jpietrowiak

Zen Follower

Join Date:
May 2009
Posts:
122
Plugin Contributions:
0

Re: Google Ecommerce Tracking

Just tested with New install of Zen 1.5.4 with sampel products. It does pass the brand on checkout page. HOWEVER.. the brand is not accurate. Here is an example of checked out items. You can see they are mismatched.

ga('ec:addProduct', {   'id': '8', 'name': 'A Bug\'s Life Linked', 'brand': 'Microsoft', 'category': 'Cartoons', 'variant': 'n/a', 'price':  '35.99', 'quantity': '1', 'coupon': 'n/a', 'position': '0' } );
ga('ec:addProduct', {   'id': '105', 'name': 'A Maximum Sample of 1', 'brand': 'Matrox', 'category': 'Big Linked', 'variant': 'n/a', 'price':  '50.00', 'quantity': '1', 'coupon': 'n/a', 'position': '1' } );
11 Dec 2017, 4:21 AM
#73
jpietrowiak avatar

jpietrowiak

Zen Follower

Join Date:
May 2009
Posts:
122
Plugin Contributions:
0

Re: Google Ecommerce Tracking

I think I found code bug after trying again for a few hours. This will be my first commit. I submitted problem in Github too as not sure of process. Please double check my work though. Not sure if I should try to submit to zencart. The analytics problem from this is that it causes the brand name only for checked out items to be incorrect. All browsing experience on product pages will record brand properly. In reports though for checked out items in which someone wants to see total sales by brand name it will be incorrect.

Change line 217 of file in includes/classes/observers/class.ec_analytics.php

Change below code from "orders_products_id" to "products_id"

$brand = zen_get_products_manufacturers_name($items_in_cart->fields['orders_products_id']); 
11 Dec 2017, 5:39 PM
#74
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

Re: Google Ecommerce Tracking

jpietrowiak:

I think I found code bug after trying again for a few hours. The analytics problem from this is that it causes the brand name only for checked out items to be incorrect. All browsing experience on product pages will record brand properly. In reports though for checked out items in which someone wants to see total sales by brand name it will be incorrect.

Change line 217 of file in includes/classes/observers/class.ec_analytics.php

Change below code from "orders_products_id" to "products_id"

$brand = zen_get_products_manufacturers_name($items_in_cart->fields['orders_products_id']);


Thanks for reporting this typo preventing the brand name to be recorded!
Fix confirmed, just submitted an updated 1.2.1 to the download section.
18 Apr 2018, 7:53 AM
#75
meksicus avatar

meksicus

New Zenner

Join Date:
Jul 2015
Location:
Warsaw
Posts:
16
Plugin Contributions:
0

Re: Google Ecommerce Tracking

hello.
Currently, Google implements gtag for tracking sites, instead of ga.
Can this mod be reweiten using this new library?

Regards
Meksicus

20 May 2018, 11:09 AM
#76
adrian_cioc_rlan avatar

adrian_cioc_rlan

New Zenner

Join Date:
May 2016
Location:
Bucharest
Posts:
48
Plugin Contributions:
0

Re: Google Ecommerce Tracking

Can anyone tel how to anonymise ip with module, where to put the code so that the visitor's ip is anonymised in Google Analytics?
I read that this code should be inserted in the GA snippet ---- ga('set', 'anonymizeIp', true); --- but not sure where it should go in the EC Analytics Module, and also how to test if it does the job.

Also, is this module sending user ID information to Google Analytics? We don't want this information to be sent by our website to GA.

Need these handeled to make our GA GDPR compilant without the need to gather consent from visitors to run GA.

10x

20 May 2018, 5:05 PM
#77
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

Re: Google Ecommerce Tracking

To use anomyzizeIP with this plugin:

includes/templates/YOURTEMPLATE/jscript/jscript_ec_analytics.php

around line 29
change from

<?php
//global $analytics, $cID;
$cID = (isset($_SESSION['customer_id'])) ? "customerID#".$_SESSION['customer_id']:"guest";
echo ($cID === "guest") ? "ga('create', '".$trackingID."', 'auto') ;\n":"ga('create', '".$trackingID."', {'userId':'{$cID}'});\n";   
echo "ga('require', 'ec');\n"; 
echo "ga('require', 'displayfeatures');\n";
if (!isset($_SESSION['analytics'])) {  echo "ga('send', 'pageview');\n";} 

to

<?php
global $analytics, $cID; 
$cID = (isset($_SESSION['customer_id'])) ? "customerID#".$_SESSION['customer_id']:"guest";
echo ($cID === "guest") ? "ga('create', '".$trackingID."', 'auto') ;\n":"ga('create', '".$trackingID."', {'userId':'{$cID}'});\n";
echo "ga('set', 'anonymizeIp', true); \n";     
echo "ga('require', 'ec');\n"; 
echo "ga('require', 'displayfeatures');\n";
if (!isset($_SESSION['analytics'])) {  echo "ga('send', 'pageview');\n";} 

To be GDPR compliant you should also support the GA Opt-Out Cookie:

Integrate the following link to your privacy policy:

<a onclick="alert('Google Analytics has been disabled');"href="javascript:gaOptout()">Disable Google Analytics</a>

And integrate the following script somewhere in the head section in includes/templates/YOURTEMPLATE/common/html_header.php
(Change UA-1234567 to your own ID)

<script type="text/javascript">
var gaProperty = 'UA-1234567';
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) { window[disableStr] = true;
}
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true; }
</script>

The user ID is sent to Google Analytics but this does not contain any personal data so I' m not sure what should not be GDPR compliant doing so.

21 May 2018, 12:47 PM
#78
adrian_cioc_rlan avatar

adrian_cioc_rlan

New Zenner

Join Date:
May 2016
Location:
Bucharest
Posts:
48
Plugin Contributions:
0

Re: Google Ecommerce Tracking

webchills:

To use anomyzizeIP with this plugin:

includes/templates/YOURTEMPLATE/jscript/jscript_ec_analytics.php

around line 29
change from

<?php //global $analytics, $cID; $cID = (isset($_SESSION['customer_id'])) ? "customerID#".$_SESSION['customer_id']:"guest"; echo ($cID === "guest") ? "ga('create', '".$trackingID."', 'auto') ;\n":"ga('create', '".$trackingID."', {'userId':'{$cID}'});\n"; echo "ga('require', 'ec');\n"; echo "ga('require', 'displayfeatures');\n"; if (!isset($_SESSION['analytics'])) { echo "ga('send', 'pageview');\n";} ``` > > to > > ``` <?php global $analytics, $cID; $cID = (isset($_SESSION['customer_id'])) ? "customerID#".$_SESSION['customer_id']:"guest"; echo ($cID === "guest") ? "ga('create', '".$trackingID."', 'auto') ;\n":"ga('create', '".$trackingID."', {'userId':'{$cID}'});\n"; echo "ga('set', 'anonymizeIp', true); \n"; echo "ga('require', 'ec');\n"; echo "ga('require', 'displayfeatures');\n"; if (!isset($_SESSION['analytics'])) { echo "ga('send', 'pageview');\n";} ``` > > To be GDPR compliant you should also support the GA Opt-Out Cookie: > > Integrate the following link to your privacy policy: > > ``` <a onclick="alert('Google Analytics has been disabled');"href="javascript:gaOptout()">Disable Google Analytics</a> ``` > > And integrate the following script somewhere in the head section in includes/templates/YOURTEMPLATE/common/html_header.php > (Change UA-1234567 to your own ID) > > ``` <script type="text/javascript"> var gaProperty = 'UA-1234567'; var disableStr = 'ga-disable-' + gaProperty; if (document.cookie.indexOf(disableStr + '=true') > -1) { window[disableStr] = true; } function gaOptout() { document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/'; window[disableStr] = true; } </script> ``` > > The user ID is sent to Google Analytics but this does not contain any personal data so I' m not sure what should not be GDPR compliant doing so. Thanks, I inserted the code, but how do I test if the ip is indeed anonimysed? Also, the disable GA script seems to work but what if the user wants to re enable Google Analytics back, how is this done?
21 May 2018, 1:36 PM
#79
webchills avatar

webchills

Zen Follower

Join Date:
Sep 2005
Location:
Austria
Posts:
99
Plugin Contributions:
1

Re: Google Ecommerce Tracking

but how do I test if the ip is indeed anonimysed

Use Chrome

Install the Google Analytics Debugger extension
https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en

Go to your website

Check the requests sent to Google Analytics, they should have the &aip parameter set to aip=1

but what if the user wants to re enable Google Analytics back

He has to delete the Opt-Out Cookie

Use Firefox Version 60 and above

Go to your website

Click on Site Information > Website Security > more info > show cookies
If the GA Opt-Out Cookie is set you will see:
ga-disable-UA-12345678-9
If you delete this cookie GA is "enabled" again

21 May 2018, 1:41 PM
#80
adrian_cioc_rlan avatar

adrian_cioc_rlan

New Zenner

Join Date:
May 2016
Location:
Bucharest
Posts:
48
Plugin Contributions:
0

Re: Google Ecommerce Tracking

webchills:

Use Chrome

Install the Google Analytics Debugger extension
https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en

Go to your website

Check the requests sent to Google Analytics, they should have the &aip parameter set to aip=1

He has to delete the Opt-Out Cookie

Use Firefox Version 60 and above

Go to your website

Click on Site Information > Website Security > more info > show cookies
If the GA Opt-Out Cookie is set you will see:
ga-disable-UA-12345678-9
If you delete this cookie GA is "enabled" again

10x so much, appreciate!