Posts Tagged ‘Google Analytics’
Virtual Page views using Google Analytics is an essential feature to track visitors within your site and to have a good idea as to where customers leave the conversion process. Virtual page views are used when traditional page views are not recorded and an alternative traking convention is required.
Virtual page views are very helpful because any kind of activity can be represented and tracked if the code is paced properly. An interaction involving playing a flash video, for example, would not normally be recorded as an action by analytics, although by setting the visitor interaction as a virtual page view, it can be accomplished. In other words, even if a page hasn’t actually been loaded, by setting it as ‘virtual’ Google Servers receive information that a page view has just been enacted.The main argument which is called during implementing this is _trackPageview()
Again, first the standard Google Analytics Tracking code must be implemented in the source code on the main server hosting the site. So your code should look like this I will provide a sample:
<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”>
var pageTracker = _gat._getTracker(”UA-7799676-1″);
pageTracker._trackPageview();
</script
The main argument here is the _trackPageView method, however for each element tracked, the trackPageView() method must specify a name for each event, thus if you would like to track a step in the purchase process and state it step 1 in the purchase funnel, within the track page view parenthesis, the code will be:
pageTracker._trackPageview(”/purchase_funnel/Step1.html”);
-However remember that what is in the parenthesis varies and you must adopt a consistent naming convention in Analytics.
Also, a Download can be tracked by inserting the _trackPageView argument inside a hyperlink as follows:
<a href=http://www.example.com onClick= “javascript: pageTracker._trackPageview(’download/example.pdf’);”>
This code makes it possible for a download to count as a page view and thus an additional step in the conversion process.
In all, virtual page views are essential when tracking visitors through the conversion process and viewing the funnel visualization in analytics which is a great visual of when you lose customers. This can give a clear picture as to what works in the conversion process and what doesn’t.
Some websites may benefit from having linked domains and/or sub-domains whether they are both owned by a parent company, are partners, or are related in some way and can provide interconnected data in order to send cookie information from one site to another. This can aid with identifying a websites source of referral traffic and act as a funnel in which visitors can be more accurately identified as either unique or recurring. Google Analytics uses 1st Party cookies thus using certain arguments to link cookie information between domains is useful and worthwhile process.
Firstly, access to your web server is needed and implanting of the Google Analytics tracking code is required on all pages of both domains. Example is as shown:
<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”>
var pageTracker = _gat._getTracker(”UA-7799676-1″);
pageTracker._trackPageview();
</script>
Now, before the </script> and trackPageview() ,
Insert the _setDomainName(”None”) _setAllowLinker(true); arguments into your code.
It should look like:
<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”>
var pageTracker = _gat._getTracker(”UA-7799676-1″);
pageTracker._setDomainName(”None”);
pageTracker._setAllowLinker(”true”);
pageTracker._trackPageview();
</script>
After the code highlighted in bold is inserted, call the _link() method to all links in between domains.
We will use an example linking Yourwebsite.com with yourotherwebsite.com by allowing cookie information to be shared using the link method. The following code using an example website:
On www.yourwebsite.com:
<a href= http://yourwebsite.com
Onclick=”pageTracker._link(’http://www.yourwebsite.com’);return false;”>Go to our sister site Yourotherwebsite.com</a>
Likewise, on www.yourotherwebsite.com use this code:
<a href= http://yourotherwebsite.com
Onclick=”pageTracker._link(’http://www.yourotherwebsite.com’);return false;”>Go to our sister site yourwebsite.com</a>
The link method allows for cookie information to transfer between different domains when the user clicks on the link to transfer to a different domain. The visitor’s session information will be preserved through first party cookies. Unfortunately, the link method does not work through means other than clicking on a link. If session information is wished to be preserved through other means, like a form, the _linkByPost() method must be used. An example would be:
<form action=http://www.exampleshoppingcart.com/service/formprocessor.php
Name=”f” method= “post” onsubmit=”pageTracker._linkbyPost(this)”>
(Other Misc. Content here…)
</form>
Tracking across multiple Subdomains is very useful for domains that are a part of larger domains if you would like tracking to span across different webpages organized into different departments, groups, etc. For example if your website is organized so that the shopping cart is directed to the url: cart.yourwebsite.com from yourwebsite.com, then in order to transfer cookie information between the parent domain and the sub-domain, the following steps must be followed:
First the standard ga.js tracking code must be implemented on the main web server for the code on that page of course, although a new line of code must be inserted after the var pageTracker argument is called which is the _setDomainName method. The following is what the code should look like. The highlighted text represents the argument that will preserve cookie information when a user is transferred from your parent domain to your sub-domain. This code will allow GA to track the visitor and identify that visitor as a referred visitor.
Google Tracking code inserted here…
</script>
Var pageTracker=_gat._getTracker(”Insert UA ID # here”);
pageTracker._setDomainName(”.yourmaindomain.com”);
pageTracker._trackPageview();
</script>
Again, once the parent domain is referenced, GA will share 1st party cookie information and transfer them from domain to sub-domain. In addition to linking domains with sub-domains Google Analytics also allows users to track across multiple domains with sub-domains.
In order to do this, additional code is required to set up on each sub-domain and primary domain. In order to do this you must call the _setAllowHash argument which will allow for cookie session information to be exchanged between multiple domains with sub-domains.
(Google Analytics tracking code must be inserted here)
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(”UA-7799676-1″);
pageTracker._setDomainName(”None”);
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
pageTracker._trackPageview();
</script>
After this code is inserted on the host server for all the domains and sub-domains that you wish to be linked, the _link() or _linkbyPost() method can be used to track all links and/or forms between each domain. Note that these methods are not needed for all links or forms between sub-domains of the same domain only sub-domains of different domains.
On www.yourwebsite.com:
<a href= http://yourwebsite.com
Onclick=”pageTracker._link(’http://www.yourwebsite.com’);return false;”>Go to our sister site Yourotherwebsite.com</a>
Likewise, on www.yourotherwebsite.com use this code:
<a href= http://yourotherwebsite.com
Onclick=”pageTracker._link(’http://www.yourotherwebsite.com’);return false;”>Go to our sister site yourwebsite.com</a>
Again plant this code on all links/forms between your different domains as before except between sub-domains on the same domain.
E-commerce tracking using Google Analytics is likely the most useful feature of the program as it allows for in-depth analysis of important e-commerce metrics such as Revenues generated from products sold, specific product performance, conversion rates, average order value and more. If operating an e-commerce store, analysis of these metrics can result in significant performance gains as it makes it easier to understand customer behavior and areas for improvement. In order to plant the code, you will need access to your main web server hosting your web site coding in order to insert GA code where necessary. Remember, what we’re doing here is injecting information from your web server and funneling it to the GA server which spits out the data back to you in a form that is able to be accessed in a useful format. First, before any of these features can be utilized, the e-commerce feature must be enabled as shown below:
First Select Analytics Settings>Profile Settings>Edit Profile information>Enable E-commerce by selecting YES, an E-Commerce Site

Once E-commerce is enabled, GA tracking code must be added to your receipt page and then some additional code must be implemented to track and log each transaction. In order to track each transaction the following code must be implemented into the receipt page:
First add standard Google Analytics tracking code to the receipt page. This tracking code will vary based on your specific profile; however an example is as shown:
<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-7799676-1″);
pageTracker._trackPageview();
</script>
Next on the receipt page after standard ga.js tracking code enter the following code before </script> enter the following code: Note that your merchant software provider is required to dynamically retrieve information from the fields below:
pageTracker._addTrans(
“Order ID-required”
“Affiliation or store name-optional”
“Total-required”
“Tax-optional”
“Shipping-optional”
“City-optional”
“State-optional”
“Country-optional”
);
Next add pageTracker._addItem(
“Order ID-required”
“SKU/Code-optional”
“Product Name-optional”
“Category-optional”
“Unit price-required”
“Quantity-required”
);
Lastly add: pageTracker._trackTrans();
Finish code with </script>
The trackTrans() argument is vital because it sends all information to GA server and records the transaction giving you the data. Essentially the trackTrans argument sends the data from your server to GA by requesting for the _utm file twice, once for the transaction taking place and once for each item purchased.
An example of what the coding for the final receipt page should look like:
<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 type=”text/javascript”>
try {
var pageTracker = _gat._getTracker(”UA-7799676-1″);
pageTracker._trackPageview();
pageTracker._addTrans(
“Order ID-required”
“Affiliation or store name-optional”
“Total-required”
“Tax-optional”
“Shipping-optional”
“City-optional”
“State-optional”
“Country-optional”
);
pageTracker._addItem(
“Order ID-required”
“SKU/Code-optional”
“Product Name-optional”
“Category-optional”
“Unit price-required”
“Quantity-required”
);
pageTracker._trackTrans();
</script>
Repeat this procedure at the receipt page of each product sold. Remember that code will need to dynamically retrieve the fields from your merchant software
What your E-commerce Report Tells you:
After E-commerce code is processed and working properly, essentially what you will see is an in-depth analysis of different revenue metrics. Navigating through the left hand tabs allows you to sort through specific product performance, average order values, transactions, visits to purchase, and days to purchase information.


