| View previous topic :: View next topic |
| Author |
Message |
seppo
Joined: 03 Mar 2010 Posts: 29
|
Posted: Wed Sep 15, 2010 3:19 am Post subject: Tutorial: Google Analytics goal and ecommerce tracking |
|
|
I've had problems on getting Google Analytics goal and eCommerce tracking to play ball with DLG. Finally figured it out yesterday. Here's a simple tutorial incase someone else is struggling with this also.
GOALS
If you want Google Analytics to track sales you made using DLG as goals, here's how to do it.
Goal type: URL Destination
Match type: Regular Expression Match
Goal URL: /dlg/download.php\?r=.{1,17}&p=1$
Goal value: Price of your product
In case the Goal URL looks mysterious let me briefly explain it. '?' is a special character used to match things and if we want to use it as normal '?' we have to escape, hence the '/' after php.
r=.{1,17} is used to match any receipt number. That expression matches any string that is 1 to 17 characters long. PayPal receipt numbers are 17 characters long, hence the 17 as max. In case your receipt numbers are longer just change the last number. This matches both PayPal and CB receipt numbers for me.
&p=1$ identifies your product number. So change the number to match the product number in DLG you want to track. The '$' at the end means that this has to be the end of the string. Without the '$' it would also match p=10/11/12/100 and so on.
You have to set a goal for each product you want to track.
ECOMMERCE TRACKING
Here's the code I used to eCommerce tracking. I have different thank you/download page templates for all of my products, so I just pasted this to the HTML template. I haven't tested pasting this to the 'Extra HTML' box.
Here's what you have to change:
Enter your own User Account ID. And remember to enter the one with your website profile, not the whole account code. Each of your website profiles has a different code. In the code below it's the -8 that denotes my website profile. So make sure your code also includes '-X'.
Change the price in the two instances below to match the price of your product.
That works for tracking digital info products that are sold one unit at a time. If you sell a different type of product you might need to make further changes to the code.
| Code: | <!-- Google Analytics eCommerce tracking script -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2707024-8']); // Insert User Account code here.
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'%%customerreceipt%%', // order ID - required
'', // affiliation or store name
'19.97', // total - required
'', // tax
'', // shipping
'', // city
'', // state or province
'' // country
]);
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each
_gaq.push(['_addItem',
'%%customerreceipt%%', // order ID - required
'%%productnumber%%', // SKU/code - required
'%%productname%%', // product name
'', // category or variation
'19.97', // unit price - required
'1' // quantity - required
]);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google- analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- Google Analytics eCommerce tracking script --> |
That's it.
I hope this helps someone to get going with Analytics.
Oh, and in case I have mistakes in the code, feel free to correct them. |
|
| Back to top |
|
 |
admin Site Admin
Joined: 31 Jul 2005 Posts: 9134 Location: Australia
|
Posted: Wed Sep 15, 2010 11:54 pm Post subject: |
|
|
Oh that's genius - thanks so much for sharing, Seppo!
Just out of curiosity, isn't it possible to track a goal conversion just by putting a certain snippet of Google code on your download page template?
What is the benefit of using the URL matching?
I've had other people set it up just by using the URL:
/dlg/download.php
...and ignoring the extra variables.
I'm interested in what extra "power" this gives you - is it just for more accurate tracking, or something else?
cheers
Sam _________________ Sam Stephens
DLGuard: www.dlguard.com
GuardHQ: www.guardhq.com
-------
Keep up to date with DLGuard and other GuardHQ products: www.guardhq.com/newsletter.php
www.twitter.com/DLGuard |
|
| Back to top |
|
 |
seppo
Joined: 03 Mar 2010 Posts: 29
|
Posted: Fri Sep 17, 2010 3:37 am Post subject: |
|
|
Sam,
If you just put 'dlg/download.php' then it's going to match every product you have. By putting the extra code to the end you can track each of your products separately.
As far as I know adding the extra code to the thank you page works with Website Optimizer, but not with Analytics. Analytics does it with URL matching, hence you need the complicated URL code.
Or at least that how I understand it. If I'm wrong I hope someone corrects me so there's a simpler way to do this. |
|
| Back to top |
|
 |
admin Site Admin
Joined: 31 Jul 2005 Posts: 9134 Location: Australia
|
Posted: Fri Sep 17, 2010 4:51 am Post subject: |
|
|
Oh of course, that makes perfect sense - thanks Seppo!
I'll be sure to point people to this thread next time I'm asked about tracking. Actually I might link it from a FAQ.
cheers
Sam _________________ Sam Stephens
DLGuard: www.dlguard.com
GuardHQ: www.guardhq.com
-------
Keep up to date with DLGuard and other GuardHQ products: www.guardhq.com/newsletter.php
www.twitter.com/DLGuard |
|
| Back to top |
|
 |
wiseweb
Joined: 10 Jun 2009 Posts: 34
|
Posted: Wed Jan 26, 2011 6:34 pm Post subject: expression match |
|
|
Hello,
You wrote
Goal URL: /dlg/download.php\?r=.{1,17}&p=1$
would not it be rather
Goal URL: /dlg/download\.php\?r=.{1,17}&p=1$
I've set it up your way with goal price matching your script in google analytics admin. I hope it works.
I really want this. |
|
| Back to top |
|
 |
VideoGuideToProfits
Joined: 08 Dec 2007 Posts: 146
|
|
| Back to top |
|
 |
kampyle
Joined: 14 Feb 2013 Posts: 1
|
Posted: Thu Feb 14, 2013 7:05 am Post subject: |
|
|
it could be google or any other type of analytics...they mostly function the same. _________________ wholesale rabbit skins |
|
| Back to top |
|
 |
halls7
Joined: 23 Dec 2007 Posts: 55 Location: Malta
|
Posted: Wed Mar 27, 2013 8:37 am Post subject: |
|
|
Hi,
I confirm it works, I follow instructions made a test sale with clickbank and worked perfectly, I see new goal in analytics with cb receipt number in it surely confirms it works
Thanks!
Jack _________________ OutRankSmart NoAdware |
|
| Back to top |
|
 |
|