View Full Version : Google Analytics invoice data
ILoveHostasaurus
04-07-06, 05:33 AM
So Google Analytics would like to see the following in one's invoice page to properly pass all the data back to them:
<body onLoad="javascript:__utmSetTrans()">
<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|[order-id]|[affiliation]|
[total]|[tax]| [shipping]|[city]|[state]|[country] UTM:I|[order-id]|[sku/code]|[productname]|[category]|[price]|
[quantity] </textarea>
</form>
Example
UTM:T|34535|Main Store|143.05|3.05|10.00|San Diego|CA|USA
UTM:I|34535|XF-1024|Urchin T-Shirt|Shirts|10.00|9 UTM:I|34535|CU-3424|Urchin Drink Holder|Accessories|20.00|2
Some of that is possible using the OpenUI tokens but I don't think there are tokens for all of either the transaction portion or the line item portions are there?
Bruce - PhosphorMedia
04-07-06, 05:48 AM
Well, you could use a bunch of DoFunc (or whatever they are called) OpenToken calls to loop through the order items...but on the invoice page...nah...I wouldn't risk the CPU hit...send that info to us off list and we can write a module that spits this out...that is, unless someone else has a brainer idea.
Vic - WolfPaw Computers
04-07-06, 05:49 AM
Sure there are:
[order-id] %ORDERNUM%
[affiliation] %VAR(Affiliates.d.code)% (or the viking code token if using Affiliate Manager)
[total] %ORDER_TOTAL%
[tax] %ORDER_TAX%
[shipping] %ORDER_SHIPPING%
[city] %VAR(Orders.d.ship_city)% or %VAR(Orders.d.bill_city)%
[state] %VAR(Orders.d.ship_state)% or %VAR(Orders.d.bill_state)%
[country] %VAR(Orders.d.ship_cntry)% or %VAR(Orders.d.bill_cntry)%
[sku/code] %VAR(Prodducts.d.code)%
[productname] %VAR(Products.d.name)%
[category] %VAR(Categories.d.code)%
[price] %VAR(Products.d.price)%
[quantity] %BASKET_QUANTITY|prodcode%
Problem is, on the INVC screen, you'd have to do a few extras. You would have to scan through the order line by line to extract data for each product, such as prodcode, category, price and quantity. Category data would not be available on INVC - you'd have to script a lookup to see if the product was assigned to a category and even then you would only get the first assigned category.
In either case, doing this could significantly slow down the display of the INVC screen due to the looping needed to lookup data.
jason - jmh web services
04-07-06, 10:03 AM
So Google Analytics would like to see the following in one's invoice page to properly pass all the data back to them:
<body onLoad="javascript:__utmSetTrans()">
<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|[order-id]|[affiliation]|
[total]|[tax]| [shipping]|[city]|[state]|[country] UTM:I|[order-id]|[sku/code]|[productname]|[category]|[price]|
[quantity] </textarea>
</form>
Example
UTM:T|34535|Main Store|143.05|3.05|10.00|San Diego|CA|USA
UTM:I|34535|XF-1024|Urchin T-Shirt|Shirts|10.00|9 UTM:I|34535|CU-3424|Urchin Drink Holder|Accessories|20.00|2
Some of that is possible using the OpenUI tokens but I don't think there are tokens for all of either the transaction portion or the line item portions are there?
Viking has the generic affiliate integration module (http://www.jmhonline.net/miva-modules/generic+affiliate+integration) that has a field to be run for each product. i.e. Product-Specifc HTML: (runs for each product in basket)
But the tokens available right now don't include things like city, state, etc. I'm sure adam would probably add them if requested.
Jason
sjpenkacik
04-26-06, 07:46 PM
I pasted this code into the Customer Check out headers and footers Order Completed Thank you Screen and got a non-fatal warning which said
The String contains open tokens, not starting with %OUI%.
Here is the code I pasted:
<body onLoad="javascript:__utmSetTrans()">
<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|%ORDERNUM%|%affiliate_company%|
%ORDER_TOTAL%|%ORDER_TAX%|%ORDER_SHIPPING%|%VAR(Or ders.d.ship_city)%|%VAR(Orders.d.ship_state)%|%VAR (Orders.d.ship_cntry)%|
UTM:I|%ORDERNUM%|%VAR(Prodducts.d.code)%|%VAR(Prod ucts.d.name)%|%VAR(Categories.d.code)%|%VAR(Produc ts.d.price)%|
%BASKET_QUANTITY|prodcode%| </textarea>
</form>
Is this the correct place for this to go and why am I getting the warning message?
I am using Open UI Miva 4.23.
Thank you,
Shawnee
Vic - WolfPaw Computers
04-26-06, 07:52 PM
When using OpenTokens, the text box you paste your code in must have the first 5 characters as %OUI% or it wont parse.
sjpenkacik
04-26-06, 08:07 PM
Can you give me an example?
Thank you,
Shawnee
Vic - WolfPaw Computers
04-26-06, 08:12 PM
Something like this:
netblazon
04-26-06, 08:23 PM
David,
Here's the code I have working in the invoice screen footer on one OpenUI site. I've replaced their storename with "STORENAME". Here you will notice that we're not passing the valid category code. Instead we're just passing the hardcoded string "Category":
<!-- Google Analytics -->
<form style="display:none;" name="utmform">
<textarea id="utmtrans">
UTM:T|%ORDERNUM%|STORENAME|%order_subtotal%|%order _tax%|%order_shipping%|%VAR(Orders.d.ship_city)%|% VAR(Orders.d.ship_state)% |%VAR(Orders.d.ship_cntry)%
%FUNC(OrderItem_FindFirst_Order(Orders.d.id))%%WHI LE(g.OUIX_FuncReturn)%UTM:I|%ORDERNUM%|%VAR(OrderI tems.d.code)%|%VAR(OrderItems.d.code)%|Category|%V AR(OrderItems.d.price)%|%VAR(OrderItems.d.quantity )%
%FUNC(OrderItem_FindNext_Order(Orders.d.id))%%WHIL EEND%</textarea>
</form>
On another site, we're calling a token from our Category Breadcrumbs Plus module (http://www.netblazon.com/p-nbbcp.html) to return either the primary category code (if set), or if not set, then the first assigned category code from the CatXProd.dbf file. That token is "%module|breadcrumbs|primary-code2%" and the entire code is here:
<form style="display:none;" name="utmform">
<textarea id="utmtrans">
UTM:T|%ORDERNUM%|STORENAME|%order_subtotal%|%order _tax%|%order_shipping%|%VAR(Orders.d.ship_city)%|% VAR(Orders.d.ship_state)% |%VAR(Orders.d.ship_cntry)%
%FUNC(OrderItem_FindFirst_Order(Orders.d.id))%
%WHILE(g.OUIX_FuncReturn)%
%module|CBS|goprodcode[OrderItems.d.Code]%
UTM:I|%ORDERNUM%|%VAR(OrderItems.d.code)%|%VAR(Ord erItems.d.name)%|%module|breadcrumbs|primary-code2%|%VAR(OrderItems.d.price)%|%VAR(OrderItems.d .quantity)%
%FUNC(OrderItem_FindNext_Order(Orders.d.id))%
%WHILEEND%
</textarea>
</form>
sjpenkacik
04-26-06, 08:37 PM
Okay so am I correct in saying the code should be
%OUI%
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-237569-1";
urchinTracker();
</script>
%OUI%
<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|%ORDERNUM%|%affiliate_company%|%ORDER_TOTAL% |%ORDER_TAX%|%ORDER_SHIPPING%|%VAR(Orders.d.ship_c ity)%|%VAR(Orders.d.ship_state)%|%VAR(Orders.d.shi p_cntry)%|
UTM:I| %ORDERNUM%|%VAR(Prodducts.d.code)%|%VAR(Products.d .name)%|%VAR(Categories.d.code)%|%VAR(Products.d.p rice)%|%BASKET_QUANTITY|prodcode%|</textarea>
</form>
and all go on the Customer Checkout Headers and Footers screen under Order Completed thank you.
Please advise.
Thank you for your help in advance.
Shawnee
Vic - WolfPaw Computers
04-26-06, 08:45 PM
Okay so am I correct in saying the code should be
%OUI%
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-237569-1";
urchinTracker();
</script>
Sort of.
This:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-237569-1";
urchinTracker();
</script>
Should be in your Head/Body Tag insert - in the head tag box.
This:
%OUI%
<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|%ORDERNUM%|%affiliate_company%|%ORDER_TOTAL% |%ORDER_TAX%|%ORDER_SHIPPING%|%VAR(Orders.d.ship_c ity)%|%VAR(Orders.d.ship_state)%|%VAR(Orders.d.shi p_cntry)%|
UTM:I| %ORDERNUM%|%VAR(Prodducts.d.code)%|%VAR(Products.d .name)%|%VAR(Categories.d.code)%|%VAR(Products.d.p rice)%|%BASKET_QUANTITY|prodcode%|</textarea>
</form>
Should be in your Invoice Footer.
netblazon
04-26-06, 09:09 PM
Shawnee,
Let's back up a little...
Step 1 - On the left side of admin, click you store name. On the right side, click Head/Body Tags. In Body Tag Insert, enter:
%OUI% %IF(g.screen EQ 'INVC' AND NOT g.Data_Entry_Error)%onload="javascript:__utmSetTrans()"%IFEND%
Step 2 - On the right side still, click Hdr/Ftr - Global. Enter the following at the end of the Global Screen Footer (replacing 999999 with your number!):
<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-999999-1";
urchinTracker();
</script>
Step 3 - Still on the right side, click Hdr/Ftr - Checkout Screens. In the Invoice Footer, enter something like this:
<form style="display:none;" name="utmform">
<textarea id="utmtrans">
UTM:T|%ORDERNUM%|YOURSTORE|%order_total%|%order_ta x%|%order_shipping%|%VAR(Orders.d.ship_city)%|%VAR (Orders.d.ship_state)% |%VAR(Orders.d.ship_cntry)%
%FUNC(OrderItem_FindFirst_Order(Orders.d.id))%
%WHILE(g.OUIX_FuncReturn)%
%module|CBS|goprodcode[OrderItems.d.Code]%
UTM:I|%ORDERNUM%|%VAR(OrderItems.d.code)%|%VAR(Ord erItems.d.name)%|CATEGORY|%VAR(OrderItems.d.price) %|%VAR(OrderItems.d.quantity)%
%FUNC(OrderItem_FindNext_Order(Orders.d.id))%
%WHILEEND%
</textarea>
</form>
Hope this helps! :)
--Susan
PS - when I preview this post, I'm seeing weird spaces in the code, like utmSetTra ns instead of utmSetTrans. I hope it doesn't come out that way when I post. If it is - shame on vBulletin, not on ME! ARGH.
Susan,
Thanks for the great step-by-step guide. Very useful to newbies like me!
Samir
Jim Cockerham
08-04-06, 04:38 PM
%VAR(OrderItems.d.price)%
Instead of the line above....
Could this line also be used using Vikings page templates to get the attribute price instaed of the product price? My products with attribute prices are not tracked in Google because they show a zero price. I don'y know if that token will only work when the attribute template is called in?
%If(hasprice)%%VAR(OrderItems.d.price)%
%ELSE%%basket_attrprice%
%IFEND%
Thanks,
Jim
Don Knowlton
10-27-06, 06:51 PM
Hello -- don't know if anyone is still monitoring this thread, but if I am looking to only track order total and order number, can I just put this in the footer of my invoice?
<form style="display:none;" name="utmform">
<textarea id="utmtrans">
UTM:T|%ORDERNUM%|%order_total%
</textarea>
</form>
thanks!
-- Don
Vic - WolfPaw Computers
10-27-06, 10:29 PM
No, you will need to put null fields in for all the other fields you dont care about.
Like: UTM:T|||||||||%ORDERNUM%|%order_total%
(I didnt count all the fields.)
It expects a finite number of fields, and in a certain order. So be sure you put enough pipes to account for the disregarded fields.
vBulletin® v3.7.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.