Google Analytics - Revenue Tracking for Actinic v8 and v9
We have developed this code over a period of a couple of weeks, and are donating it free to any Actinic users who would like to enable Google E-Commerce tracking within Analytics.
Once this code is enabled the information that you can mine from Analytics is absolutely top notch.
I am willing to give you this code for nothing – but (there is always a but!) I want a decent link back from your site to me, there – not too painful was it?.
To make it easy I have listed five different links here and would ask you to look at your nearest printer and choose the relevant code for that manufacturer, if your printer is not listed, use the last one:
Got a HP Printer? Copy and insert on your page:
-
<a href="http://www.stinkyinkshop.co.uk/acatalog/hp__Hewlett_Packard__inkjet_cartridges.html">
-
HP Inkjet Cartridges
-
</a>
Got an Epson Printer? Copy and insert on your page:
-
<a href="http://www.stinkyinkshop.co.uk/acatalog/Epson_Inkjet_Cartridges.html">
-
Epson Ink Cartridges
-
</a>
Got a Canon Printer? Copy and insert on your page:
-
<a href="http://www.stinkyinkshop.co.uk/acatalog/Canon_Printers_Inkjet_Cartridges.html">
-
Canon Ink Cartridges
-
</a>
Got a Lexmark Printer? Copy and insert on your page:
-
<a href="http://www.stinkyinkshop.co.uk/acatalog/Lexmark_Inkjet_Supplies.html">
-
Lexmark Ink
-
</a>
Not Sure? Copy and insert on your page:
-
<a href="http://www.stinkyinkshop.co.uk">
-
Printer Ink
-
</a>
On to the code…
This guide assumes you have already installed analytics on the rest of your site. If not, the article How do I add tracking code to my website? should help you out.
Enable e-commerce tracking

Install the scripts
Download the main roi script from http://www.stinkyinkshop.co.uk/roi-example.js and rename it to roi.js make sure you adjust all the items in the OPTIONS section to match your own site.
Download jQuery from http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.1.min.js rename it to jquery.js
Place roi.js and jquery.js into your actinic ’site’ directory.
Set Actinic Page Type to ‘Receipt’

Place the following changes into the section of ‘Receipt Page Layout’
-
<script language="javascript" type="text/javascript" src="jquery.js"></script>
-
<script language="javascript" type="text/javascript" src="roi.js"></script>
Wrap Actinic Variables with span tags.
The roi script needs a way of referencing each of the Actinic variables, we can do this by wrapping each of them with a span tag and giving them a class. This could easily work with another shopping cart system as long you have a way of accessing the receipt templates.
.receipt_order_id in ‘Receipt Order Number’ layout

-
<span class="receipt_order_id"><Actinic:Variable Name="TheOrderNumber"/></span>
.receipt_total in ‘Total Row’ layout

-
<span class="receipt_total"><Actinic:Variable Name="Total"/></span>
.receipt_tax in ‘Tax 1 Row’ layout

-
<span class="receipt_tax"><Actinic:Variable Name="Tax1"/></span>
.receipt_shipping in ‘Shipping Charge Row’ layout

-
<span class="receipt_shipping"><Actinic:Variable Name="Shipping"/></span>
.receipt_town & .receipt_county in ‘Receipt Invoice Address Details’ layout

-
<span class="receipt_town"><Actinic:Variable Name="InvoiceAddress3"/></span>
-
<span class="receipt_county"><Actinic:Variable Name="InvoiceAddress4"/></span>
.receipt_line, .receipt_price in ‘Product Line Row’ layout
The .receipt_line class has to be added so the roi script can loop through each product row.

-
<tr class="receipt_line">
-
<td colspan="<Actinic:Variable Name="ProductColSpan"/>" class="cart">
-
<actinic:variable name="CartProductDetails" />
-
</td>
-
<actinic:block if="%3cactinic%3avariable%20name%3d%22IsPriceInCart%22%20%2f%3e" >
-
<td align="right" class="cart">
-
<span class="receipt_price"><Actinic:Variable Name="Price"/></span>
-
</td>
-
<td align="right" class="cart">
-
<Actinic:Variable Name="Cost"/>
-
</td>
-
</actinic:block>
-
</tr>
.receipt_reference, .receipt_name, .receipt_quantity in ‘Cart Product Details’ layout

-
<span class="receipt_reference"><Actinic:Variable Name="ProdRef"/></span>
-
-
<span class="receipt_name"><Actinic:Variable Name="ProductNameOnline"/></span>
-
-
<span class="receipt_quantity"><Actinic:Variable Name="Quantity"/></span>
.receipt_category & .receipt_country_code
If you have a way of setting .receipt_category & .receipt_country_code values they will be automatically used instead of the default variables set in the roi script.
All Done!
Update your site and wait 24 hours for Google to start showing your stats.













February 28th, 2008 at 3:18 pm
[...] Implementing Google E-Commerce in Analytics [...]
March 13th, 2008 at 4:24 pm
I’m probably being very dumb here but I simply cannot get this to work.
I have changed everything in the Options as you suggest but I cannot for the life of me figure out what my product category is or what my shop is called in Google Analytics. I’ve tried various combinations and none work. Just where does Google hide these things on the analytics site?
All the customisation of the receipt page is OK and all the scripts are where they should be. I’m now stumped but I presume the problem lies with the incorrect options.
Any advice would be gratefully received.
March 13th, 2008 at 4:50 pm
You can set the name of your shop and category to anything you want.
i.e.
// — OPTIONS —
store_name = ‘ExoticAndOriental’;
default_country_code = ‘UK’;
default_category = ‘Gifts’;
tracking_code = ‘UA-1234567-1′;
March 13th, 2008 at 5:03 pm
Thanks for the swift response.
I’ve now changed the roi.js as you have suggested with Exotic as the shop & oriental gifts as the category so it’s finger crossed!
March 14th, 2008 at 6:02 pm
Sorry guys but it’s just not working. I’ll give it another 24 hours but I do not expect there to be any difference. Obviously I have got something wrong if this is working on your Actinic store so apologies for not being able to configure what would be an excellent revenue tracker.
September 9th, 2008 at 4:47 pm
I couldn’t get this working either.
This is the preferred approach for me, and i’d love for it to have worked, but sadly, its throwing up all sorts of js errors.
the errors center around this line in roi js:
price = $(’.receipt_price’, this).text().replace(/[^0-9]/|>, ”);
…the regex you use isnt valid.
isnt this the correct regex?: /^[0-9]+$/
September 9th, 2008 at 4:57 pm
..additionally, your script is missing and end curly brace.
September 9th, 2008 at 6:14 pm
Wordpress is seriously messing with the code, so i’ve linked to it externally!
Regarding the regex, I’m using the ^ to negate the expression so it’s inside the brackets (Delete everything but the numbers). I also only wanted it to strip the first alphanumeric character it come across. This is usually a pound sign which analytics doesn’t like very much