Mark Kostner
01-17-2010, 05:07 AM
Hi Guys,
We've been working on an easy and fast way to setup google analytics tracking for a while now and I'd really like to thank john for adding the new feature "html footer" in packages.
I just though I take a minute and show everyone just how quick and easy it is now to setup google analytics tracking in your packages.
Here's one complete code snippet for you to put into the html footer field of your packages:
[]
<!-- google Analytics code Begin-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {var pageTracker = _gat._getTracker("UA-xxxx-x");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview("/goals/order_1_#{Package.id}");} catch(err) {}
</script>
<!-- google Analytics code End-->
[]
[]
<!-- google Analytics code Begin-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {var pageTracker = _gat._getTracker("UA-xxxx-x");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview("/goals/order_2_#{Package.id}");} catch(err) {}
</script>
<!-- google Analytics code End-->
[]
[]
<!-- Google adwords Code for DMS Bonus BWMS Conversion Page -->
<!-- google Adwords code End-->
<!-- google Analytics code Begin-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxx-x");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview("/goals/sale_#{Sale.prod_id}");
pageTracker._addTrans(
"#{Sale.id}", // Order ID required
"#{Affiliate.referer_id}", // Affiliate ID
"#{Sale.amountMath}", // Total
"", // Tax
"", // Shipping
"#{Customer.city}", // City
"#{Customer.state}", // State
"#{Customer.country_name}" // Country
);
pageTracker._addItem(
"#{Sale.id}", // Order ID required
"#{Sale.prod_id}", // Product ID
"#{Sale.prod_title}", // Product Name
"", // Category
"#{Sale.amountMath}", // Price required
"#{Sale.qty}" // Quantity required
);
pageTracker._trackTrans();
} catch(err) {}</script>
<!-- google Analytics code End-->
<!-- google website optimiser code Begin-->
<!-- google website optimiser code End-->
[]
Here's how it all works.
Firstly notice the: [[if Is1stOrderPage]] tags.
Using these tags allows us to run the GA specific to these pages. You'll notice that for each one of these pages we've used the following customised code:
pageTracker._trackPageview("/goals/order_1_#{Package.id}")
this let's us track each order page that the visitor lands on individually along with the product ID of that they are ordering.
For the sale page we use this code:
pageTracker._trackPageview("/goals/sale_#{Sale.prod_id}")
Once again it allows us to track which visitors arrive at the sales page and the specific product that they ordered.
We also us the Google analytics ecommerce tracking so we can track right down to who bought what and when. you can find the ecommerce code within the [[if IsThankYouPage]] tags.
All you need to do is add the following line to your normak GA code:
pageTracker._addTrans(
"#{Sale.id}", // Order ID required
"#{Affiliate.referer_id}", // Affiliate ID
"#{Sale.amountMath}", // Total
"", // Tax
"", // Shipping
"#{Customer.city}", // City
"#{Customer.state}", // State
"#{Customer.country_name}" // Country
);
pageTracker._addItem(
"#{Sale.id}", // Order ID required
"#{Sale.prod_id}", // Product ID
"#{Sale.prod_title}", // Product Name
"", // Category
"#{Sale.amountMath}", // Price required
"#{Sale.qty}" // Quantity required
);
pageTracker._trackTrans();
Basically you can copy and paste the whole code snippet I provided above and just change the UA code to match your own. and viola - it works.
The ecommerce code uses delavo's own tags to populate the required ecommerce data for google anayltics.
The beuty of using this is that you can use the same code snippet without having to change anything but the UA code for different sites.
I hope this information is usefull for anyone wanting to track their sales using google analytics.
Mark
We've been working on an easy and fast way to setup google analytics tracking for a while now and I'd really like to thank john for adding the new feature "html footer" in packages.
I just though I take a minute and show everyone just how quick and easy it is now to setup google analytics tracking in your packages.
Here's one complete code snippet for you to put into the html footer field of your packages:
[]
<!-- google Analytics code Begin-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {var pageTracker = _gat._getTracker("UA-xxxx-x");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview("/goals/order_1_#{Package.id}");} catch(err) {}
</script>
<!-- google Analytics code End-->
[]
[]
<!-- google Analytics code Begin-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {var pageTracker = _gat._getTracker("UA-xxxx-x");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview("/goals/order_2_#{Package.id}");} catch(err) {}
</script>
<!-- google Analytics code End-->
[]
[]
<!-- Google adwords Code for DMS Bonus BWMS Conversion Page -->
<!-- google Adwords code End-->
<!-- google Analytics code Begin-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxx-x");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview("/goals/sale_#{Sale.prod_id}");
pageTracker._addTrans(
"#{Sale.id}", // Order ID required
"#{Affiliate.referer_id}", // Affiliate ID
"#{Sale.amountMath}", // Total
"", // Tax
"", // Shipping
"#{Customer.city}", // City
"#{Customer.state}", // State
"#{Customer.country_name}" // Country
);
pageTracker._addItem(
"#{Sale.id}", // Order ID required
"#{Sale.prod_id}", // Product ID
"#{Sale.prod_title}", // Product Name
"", // Category
"#{Sale.amountMath}", // Price required
"#{Sale.qty}" // Quantity required
);
pageTracker._trackTrans();
} catch(err) {}</script>
<!-- google Analytics code End-->
<!-- google website optimiser code Begin-->
<!-- google website optimiser code End-->
[]
Here's how it all works.
Firstly notice the: [[if Is1stOrderPage]] tags.
Using these tags allows us to run the GA specific to these pages. You'll notice that for each one of these pages we've used the following customised code:
pageTracker._trackPageview("/goals/order_1_#{Package.id}")
this let's us track each order page that the visitor lands on individually along with the product ID of that they are ordering.
For the sale page we use this code:
pageTracker._trackPageview("/goals/sale_#{Sale.prod_id}")
Once again it allows us to track which visitors arrive at the sales page and the specific product that they ordered.
We also us the Google analytics ecommerce tracking so we can track right down to who bought what and when. you can find the ecommerce code within the [[if IsThankYouPage]] tags.
All you need to do is add the following line to your normak GA code:
pageTracker._addTrans(
"#{Sale.id}", // Order ID required
"#{Affiliate.referer_id}", // Affiliate ID
"#{Sale.amountMath}", // Total
"", // Tax
"", // Shipping
"#{Customer.city}", // City
"#{Customer.state}", // State
"#{Customer.country_name}" // Country
);
pageTracker._addItem(
"#{Sale.id}", // Order ID required
"#{Sale.prod_id}", // Product ID
"#{Sale.prod_title}", // Product Name
"", // Category
"#{Sale.amountMath}", // Price required
"#{Sale.qty}" // Quantity required
);
pageTracker._trackTrans();
Basically you can copy and paste the whole code snippet I provided above and just change the UA code to match your own. and viola - it works.
The ecommerce code uses delavo's own tags to populate the required ecommerce data for google anayltics.
The beuty of using this is that you can use the same code snippet without having to change anything but the UA code for different sites.
I hope this information is usefull for anyone wanting to track their sales using google analytics.
Mark