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}
{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
6 Comments:
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
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.
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
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?
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?
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