Blog Home



19 Mar

Google Analytics: The Lord of Code Modifications Part 1



When you work with Google Analytics, you should clearly understand that interface interaction takes only 60-70% of the whole work time and efforts.

Since you are supposed to know the general HTML principles, the structure of the website and its pages should be clear for you. This knowledge is required for working with code modifications.

The code modification is the way to improve the collected data. No doubt that Google is very smart, but sometimes some data should be processed manually.

In this article and the future ones we will consider all the code modifications in the following directions:

  1. Google Analytics code modifications
  2. Site code modifications for Google Analytics purposes

Main Google Analytics code modifications

At first, just for you to remember where Google Analytics code modifications should be placed:


The logic is quite simple: all the modifications which affect the collected data are placed before _trackPageview method.

So what is the reason (read – trouble) can make us amend the collected data? Let’s look through a few of them.

1) Why do I see some search engines in the referral report?

Well, sometimes it happens. Unfortunately, Google does not know some small local search engines, but for your business these search engines can bring the significant amount of the website traffic. But! You can’t see the keywords, moreover – there is an undeserved boost of referral traffic.

The way out: add the search engine by using _addOrganic method.

The pattern will be the following:

_addOrganic(newOrganicEngine, queryParamName, opt_prepend)

So, all you need to know is the search engine’s name and the query parameter.

From the example below:  the search engine is, the query parameter is a variable that contains the query. The pattern is the next: “query parameter” = “query”. So, here your query will be “q”.


Filling the template we obtain the following (the string that should be added to the GA code):

_gaq.push(["_addOrganic","", "q"]);

2) Keywords containing domain name are mostly brought by direct traffic than by search one… Aren’t they?

If you do think so, you’d better use _addIgnoredOrganic method.

The pattern will be the following:


You need to take a look at organic keywords (for example, Imcredo): if you find such versions as,,,, all you need is to add the following strings to the code:

_gaq.push(['_addIgnoredOrganic', '']);

_gaq.push(['_addIgnoredOrganic', '']);

_gaq.push(['_addIgnoredOrganic', '']);

_gaq.push(['_addIgnoredOrganic', '']);

3) I want this traffic to be displayed as direct, not referral

It happens when some partners or the company’s internal  sites bring traffic. If fact, this is the referral traffic type, but it is considered as direct; _addIgnoredRef method helps here.

The pattern will be the following:


List all the specific sites in that way:

_gaq.push(['_addIgnoredRef', '']);

_gaq.push(['_addIgnoredRef', '']);


After applying all the modifications listed above ,the whole GA code will look like:


Finally, the GA profile statistics will be clear and you will hopefully be satisfied.

In the next episode: a web analyst goes to the site code! Bloody epic battle or peaceful coexistence?

Leave a Reply

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