Home > Web Analytics > How to customize Google Analytics Report using API

How to customize Google Analytics Report using API

Google analytics is one of the javascript based tracking method. Initially Google have introduced Urchin code, due to some disadvantage google introduced ga.js for the tracking purpose. Ga.js is created using oops concept for ease of use, in the second part of code you can see that ‘var pagetracker’ is created as a variable acts as an object here. pageTracker._trackPageview(); in this line pageTracker calls the method called trackPageview() which is going to track the whole set of report on the page. Using pageTracker only we are going to customize the analytics report by means of calling various methods.

<script type=”text/javascript”>
try {
var pageTracker = _gat._getTracker(“UA-xxxxxxx-1”);
pageTracker._trackPageview();
}
catch(err) {}
</script>

How to convert organic search traffic into direct traffic:

_addIgnoredOrganic(newIgnoredOrganic)

This method will ignore the organic search traffic from the report. If your analytics report having organic search traffic by the name of your company. You want this traffic into direct instead of organic. For that you can use the following snippet

<script type=”text/javascript”>
try {

var pageTracker = _gat._getTracker(“UA-xxxxxxx-x”);

pageTracker._trackPageview();

pageTracker._addIgnoredOrganic(“your-company-name.com”);—->code for your company name removal from organic result
} catch(err) {}
</script>

This snippet will remove your-company-name.com from organic traffic report. For example If you have a company name of ABC and you are doing direct marketing for your company so the people search on the internet by ABC which is comes into the organic search traffic. For this situation you can remove the ABC organic into direct by using pageTracker._addIgnoredOrganic(“ABC”)

For clear all strings set in the keyword report by ._ clearIgnoredOrganic(“your-company-name”)

How to change referral traffic into direct using analytics:

_addIgnoredRef(newIgnoredReferrer)

If you want to remove your sister concern referral traffic into direct then the following snippet will solve the concern

<script type=”text/javascript”>
try {
var pageTracker = _gat._getTracker(“UA-xxxxxxx-x”);

pageTracker._trackPageview();

pageTracker._addIgnoredRef(“sister-company.com”);——->code for your sister company website referral ignorance code
}
catch(err) {}
</script>

For example If you have a sister company site viz ABC.com and you are receiving referral traffic through this site. So you want to remove this site traffic from the referral traffic. For this situation you can remove the ABC.com referral traffic into direct traffic by using pageTracker._addIgnoredRef(“ABC.com”)

For clear all items previously set for exclusion from the Referring Sites report ._clearIgnoredRef(“sister-company.com”)

How to use Two Analytics tracking code for a single page:

Suppose you have created one page for your client on your website, so that you want to give the detail report of the client page separately. For that you need to put this kind of tracking code to the client page. First account is your google analytics code and second account for the client using separate variable called pageTracker1

<script type=”text/javascript”>
try {

var pageTracker = _gat._getTracker(“UA-xxxxxxx-x”);——>First Account

pageTracker._trackPageview();

Var pageTraker1= _gat._getTracker(“UA-yyyyyy-y”);——–>Second Account

pageTraker1._trackPageview();
} catch(err) {}
</script>

How to Track a Anchor & Form tag links using Google analytics tracking:

_link(targetUrl, useHash)

This method uses HTTP GET method while passing the parameters.

<a href=”http://www.newsite.com” onclick=”pageTracker._link(‘http://www.newsite.com’);return false;”>Go to our sister site</a>

You must also enable linking on the target site (pageTracker._setAllowLinker(true);) in order for link to work properly.

_linkByPost(FormObject, useHash)

This method uses HTTP POST method while passing the parameter

In this snippet we can track the user activity on the 3rdparty shopping cart. In addition to this we need to enable the pageTracker._setAllowLinker(true)

Disclaimer: The post is completely based on individual thoughts and SEO Services Group bears no responsibilities for the thoughts reflected in the post.

Filed Under Web Analytics
2 comments on “How to customize Google Analytics Report using API
  1. Javs says:

    In setting up the two accounts as stated above,are we giving the admin rights to the second user or only the user rights? Why don’t we provide just from the analytics configuration page instead of placing the code in Website?

  2. Pandiyarajan says:

    This would be helpful like the below criteria. You provide one page to your client and you want to provide the one page information to him with a separate Google analytics account, in this criteria you can use the two account in a single analytics code.

Leave a Reply to Pandiyarajan Cancel reply

Your email address will not be published. Required fields are marked *

*

Categories