Hey guy, I want to use the new google analytics code (see below) to track my website using the ecommerce feature in analytics. What variables should be used? I'm assuming the ones outlined in the thread are suffecient? What about the category (I think this is the price group). What variable is the price group? Also do I put ALL this code on the footer.html? I would have thought that the pageTracker code would need to only be on thanks.html file, but not quite sure how I would do that (as footer comes after thanks.html) Code: <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-XXXXX-1"); pageTracker._initData(); pageTracker._trackPageview(); pageTracker._addTrans( "1234", // Order ID "Mountain View", // Affiliation "11.99", // Total "1.29", // Tax "5", // Shipping "San Jose", // City "California", // State "USA" // Country ); pageTracker._addItem( "1234", // Order ID "DD44", // SKU "T-Shirt", // Product Name "Green Medium", // Category "11.99", // Price "1" // Quantity );
Hi Ronniead, I personally load the Google Analytic information in two places: 1. In the header template across my whole site for tracking analytics, funneling, goal tracking, etc. 2. In the thanks.php for tracking completion of payments. (the code you have listed in your post) Note, if you allow users to purchase more than one product during sign up, you should include a foreach loop: Code: {foreach from=$products item=p} UTM:I|{$payment.payment_id}||{$p.title}||{$p.price}|1 </textarea> {/foreach} Another consideration is that I see only a small percentage of people make it to my thanks.php page due to the nature of the process. If your users pay via PayPal, for example, they are taken to PayPal's web page and it is only optional to click the "return to merchant" link.. Let me know if you find a better way to increase the % of users coming back to the thanks.php page
google analytics Hi, I see the issue - I'm also with Paypal... The only solution to the paypal issue (I also use paypal), I *guess* if you were really keen on getting it to work would be to do something like not even putting the ecommerce code on thanks.php, but rather, changing the paypal ipn. That way when a sale is made by paypal, the ipn somehow triggers for the ecommerce to trigger....but I'm no programmer so I would have no idea what to do. Thanks for the multiple transaction solution. I would love to be able to sell more than one item at a time, but with a mixture of radio box's an check box's. Although I may try it with just the checkbox's.....we'll see. Also any idea what the variable is for price_group? Is it p.price_group? Thanks in advance.... Ronnie
Skippybosco,am I supposed to enter this code exactly how it is or am I supposed to revise whatever is in the quotes? I am not a coder and I am trying to track my ecommerce on Google Analytics. Do I enter this code on the receipt page that says Order Complete or do I enter this code on the order confirmation page? Thanks for your help! I am desperate in getting this to work.
I'm still using the old analytics tracking, but this reference should help: You use the smarty codes in place of the values in the quotes: {foreach from=$products item=p} UTM:I|{$payment.payment_id}||{$p.title}||{$p.price}|1 </textarea> {/foreach}
Ok I dug into this a bit today. It appears that we can not use the new Google Analytics as we are unable to display Amember variables within a Javascript (or at least *I* could not find a way so if anyone can shed some light, please do!) So you end up with this at the bottom of your footer: (note to fill in your google id) and this at the bottom of your thanks.php page: (note, as in the example, it goes below the footer.html (be sure not to have two footer.html references :-p) note: I don't have tax, shipping, etc. so in those fields I have $0 and I am using a custom field for organization (data.referral)
Wanted to follow back up on this thread regarding how to improve the accuracy of transaction tracking and goal tracking within Amember. Specifically: 1) How can we use the new Analytics tracking code? Has anyone gotten it to work correctly? 2) Today that Thanks page is not seen by many users (PayPal,etc) that do not click the link to return to merchant. Is there another way to pull this off? Some "first login" code to trigger the display of the necessary data? 3) Can anyone share their goal funnel pages? I take a fairly simple approach: signup (required) -> agreement (required) -> cc (optional) -> thanks (required goal)
For the new code...throw the analytics code just before the head tag.. in header.html then in thanks.html just before the footer include do this.. While i haven't waited for it to show in google analytics.. (i'll check that tomorrow) it seems to generate the code needed correctly on a test order. {literal} <script type="text/javascript"> {/literal} pageTracker._addTrans( "{$payment.payment_id}", // Order ID "", // Affiliation "{$total|string_format:'%.2f'}", // Total "0", // Tax "0", // Shipping "{$member.city}", // City "{$member.state}", // State "{$member.country}" // Country ); {foreach from=$products item=p} pageTracker._addItem( "{$payment.payment_id}", // Order ID "", // SKU "{$p.title}", // Product Name "", // Category "{$p.price}", // Price "1" // Quantity ); {/foreach} pageTracker._trackTrans(); </script>
Hi Graham, Thanks for posting this. Have you done a view source to validate that things are displaying like they should? Do check back and let us know if it shows up in Google Analytics. I have not tried your exact code, but in the past when I tried this the variables within the javascript were not being populated correctly. Did you get around this using the literal tag?
Yes it works and yes the literal tag is what made it happen. A few real memberships have gone through it so far and they show correctly.
If you use AdBlock Plus, you might have noticed that a javascript error occurs on the google analytics code when AdBlock Plus is active. To prevent this javascript error from happening you can change the google analytics code in plugins.inc.php (version 3.2.3) slightly from this: Code: <script type="text/javascript"> var pageTracker = _gat._getTracker("$ga"); pageTracker._trackPageview(); to this: Code: <script type="text/javascript"> [COLOR="red"]try {[/COLOR] var pageTracker = _gat._getTracker("$ga"); pageTracker._trackPageview(); [COLOR="red"]} catch(err) {}[/COLOR] Erwin
Note that I corrected the code, there was a </script> too much in it. Oh and the code can be found on (or near) line 719