Smart Marketing with Google Analytics order tracking
Edward had asked about the code I used in Google Analytics to track each transaction. This allows you to see a wealth of information, not just product revenue through the website. When you add the transaction logging to your order complete or "thank you" page, google updates the basic reports it offers with an extra column so each minute piece of data can be cross referenced against the revenue it generated. For example:
- New vs returning customers - how much revenue (total and average) did each segment generate. This report can help you focus your marketing efforts to either increase first time spend or provide discounts for returning users to encourage them to buy more and reward their loyalty.
- Which referring sources were responsible for the most revenue on the site? The report columns are all sortable so rather than see which affiliate drove the most traffic to your site, which affiliate drives the biggest spenders? It can help you review your marketing spend with affiliates so you can focus your budget on the people whose visitors are more likely to buy from you.
- What is the ROI on your Google adwords campaign? One client spent nearly 3000 dollars per month on adwords campaigns that yielded just 21 dollars in revenue and one sale. He had already asked why Google drove 50% of his traffic and MSN and Yahoo were so small in comparison. I suggested that moving his adwords budget to the search engines without organic presence would make sure he had the exposure he needed at MSN and Yahoo and help adjust the balance.
The CF code I use comes in two parts. The first creates a structure of the items in his order in the act file after his order is processed:
utm_trans = structNew();
utm_trans.order_id = client.order_header_id;
utm_trans.affiliation = 'Name of the Affiliate program';
utm_trans.total = variables.grandtotal;
utm_trans.tax = variables.grandtaxes;
utm_trans.shipping = variables.grandshipcost;
utm_trans.city = get_shipaddress.city;
utm_trans.state = get_shipaddress.region;
utm_trans.country = 'USA';
utm_trans.items = queryNew('order_id,sku,productname,category,price,quantity');
//add code to populate utm_trans.items query here
</cfscript>
<cftry>
<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|#utm_trans.order_id#|#utm_trans.affiliation#|#utm_trans.total#|#utm_trans.tax#|#utm_trans.shipping#|#utm_trans.city#|#utm_trans.state#|#utm_trans.country#
<cfloop query="utm_trans.items">UTM:I|#utm_trans.items.order_id#|#utm_trans.items.sku#|#utm_trans.items.productname#|#utm_trans.items.category#|#utm_trans.items.price#|#utm_trans.items.quantity#
</cfloop></textarea>
</form>
<script language="text/javascript">
__utmSetTrans();
</script>
<cfcatch type="any"></cfcatch>
</cftry></cfoutput>
The first chunk creates the transaction wrapper (starts with UTM:T) then I loop over my collection of items to build the item rows (start with UTM:I). The last part is the __utmSetTrans() which sends the transaction to Google.
If you have found this useful or have any questions about Google Analytics, feel free to let me know in the comments section. I have worked very closely with both the code implementation and reviewing the results to make recommendations.