Cart-Lab Blog

X-Cart & E-commerce related news, resources and tips. Postings by: B00MER of Cart-Lab.com


Wednesday, November 16, 2005

Google Analytics & X-Cart

Here's a simple method to integrate Google Analytics with X-Cart 4.x. A few of the fields are missing like affiliate, however majority are populated based on order data:



Copy the above code (keeping line feeds/carriage returns in tact) to skin1/g_analytics.tpl.

Open skin1/customer/home/order_message.tpl and locate: {/section} insert the following <strong>BEFORE</strong> it:

{*** Google Analytics conversion tracking ***}
{include file="g_analytics.tpl" products=$orders[oi].products order=$orders[oi].order}


Edit skin1/customer/home.tpl and find the <body ...> tag and update accordingly:

{if $body_onload ne '' or $smarty.get.mode eq "order_message"} onload="{if $smarty.get.mode eq "order_message"}javascript:__utmSetTrans();{/if}{$body_onload}"{/if}>


Google Analytics

Labels: , , ,

Blinkbits
co.mments
Delicious
digg
Furl it!
NewsVine
Reddit
Spurl
TailRank
DZone
Google Bookmarks
taggly
Windows Live Favorites
addtoany
technorati



6 Comments:

At Tue Nov 22, 07:33:00 PM GMT-4, Blogger B00MER said...

My current stats are only for:
11/14/2005 - 11/20/2005

It seems google is taking awhile update staats so you may need to wait longer than expected to see any results.

See the webmasterworld thread:
http://www.webmasterworld.com/forum30/32017.htm

 
At Mon Mar 27, 12:43:00 PM GMT-4, Blogger minorgod said...

I notice you omit the actual urchin javascript include in your code. How did you handle the https switching with your javascrip include from Google? We use the urchin code in our whole site to track users, but on the https pages we get a security warning due to the script coming from an insecure domain. I'm planning on just doing some template tweaking to handle it, but thought you might already have an easy solution as part of your mod.

 
At Tue Mar 28, 10:07:00 PM GMT-4, Blogger B00MER said...

Minorgod,

script src=" https://ssl.google-analytics.com/urchin.js" type="text/javascript"

Details here:
http://www.google.com/support/analytics/bin/answer.py?answer=31846&topic=7169

 
At Mon Jan 22, 12:55:00 AM GMT-5, Blogger Unknown said...

I am confused as well about where to include the javascript for Analytics. I get everything else about your post, but where would you include the code from Google which contains the actual Analytics account number (obtained from the 'check status' page in the Analytics account page?

I would assume that you just need it in the head of the customers pages, so just put that in /skin1/customer/home.tpl in the head?

 
At Tue Sep 25, 01:16:00 PM GMT-4, Blogger Temp said...

I'm wondering if it's possible to fix this code. The data seems to be missing the transaction shipping, tax and product categories. Has anyone modified the g_analytics.tpl to remedy this issue?

 
At Wed Oct 31, 08:53:00 AM GMT-5, Blogger Jared Volpe said...

ThinkWebMedia,

Can you post the corrected code or get it to me otherwise? I am using 4.0.19.

Thx,

Jared

 

Post a Comment

<< Home