How to Track Outbound Links in Google Analytics

Outbound links can be tracked as Events in Google Analytics

Event tracking requires

  1. Calling trackEvent function
  2. trackEvent function can take up to 5 parameters, of those 2 are required

What are those parameters for trackEvent function

  1. category (required)The name you supply for the group of objects you want to track. It can be anything but be consistent with whatever you decide to use.I suggest using “Outbound Links”  for outbound link tracking
  2. action (required)A name for the type of user interaction for that event.  But again you can use anything you like e.g. “Click”,“Partner Link Click” or whatever makes sense for your business.I suggest that if you have different categories of link then use the category name that defines those links.
  3. label (optional)A string to provide additional description for that event.I suggest using the actual name of the links e.g. gapremium.com, google.com etc.
  4. value (optional)An integer that you can use to provide numerical data about the user event.You can leave this value in case of outbound links or use 1 unless you want to give more weights to certain links.
  5. non-interaction (optional)Boolean value, set as true or falsetrue= not a valid interaction, count it as a bounce

    false = considered a valid interaction (default)

    If you DO NOT set this value then an outbound click will be considered as a valid interaction thus WON’T BE COUNTED in BOUNCE RATE.

    Suggestion: Since you really do want people to click on outbound links, set this value to true e.g. it is a valid hit and not a bounce.

How to call it?

_gaq.push([_trackEvent(category, action, label, value, noninteraction));

Example:

_gaq.push(['_trackEvent', 'Outbound Links', 'Partner Links', 'gapremium.com', 1, true]);

 <a href=”http://www.gapremium.com” onClick=”_gaq.push(['_trackEvent', 'Outbound Links', 'Partner Links', 'gapremium.com', 1, true]);”>gapremium.com</a>

in this case gapremium.com is the external site.

Real Time Analytics in Google Analytics

What is Real Time Analytics

Real time Anaytics  in Google Analytics provides you a view of what is currently going on your site.  Current version of Google Analytics has 3 set of reports that it shows real time data for

  1. Location – Location of current visitors on your site
  2. Traffic Sources – It shows you the list of referral and keywords for the visitors currently on our sites
  3. Content – List of pages that the visitors are currently viewing

How To Get This Report

All the users of Google Analytics Latest version have this report enabled. So if you are using old version of Google Analytics, just switch to the new version and you will have this report.  It is under “Home” tab (see image below).

 

Uses of Real Time Analytics



Few cases where you might want to (or be tempted to) use Real-Time Analytics

  • You launched a new campaign e.g. paid search, email newsletter, TV ad , and would like to see how people are reacting to those campaigns.
  • You added new promotions on your site and want to see how visitors are reacting to those promotions, so that you can tweak those promotions in real time.
  • You added new stories, links etc. and want to see if anybody is clicking on them so that you can make some changes based on instant feedback. I can see the usefulness of this feature for news and media sites.
  • You made some technical changes e.g. changed tracking code and want to see if those pages are being recorded in Google Analytics. Real time reports can serve as QA tools.
  • You launched a new feature on your site, launched a video, deployed a new game and would like to know if your visitors are using it or not.

Source: http://webanalysis.blogspot.com/2011/12/do-you-need-real-time-web-analytics.html#axzz1kyVse7nG

 

How to Add AddThis Analytics in Google Analytics?

AddThis is social share widget that allows your visitors to easily share your content with others via email, social networks etc.

Add this has it’s own analytics that allows you to see what social share option e.g. Facebook, email, etc are visitors using. However, since you are already using Google Analytics, won’t it be nice if you can see your reports right within you Google Analytics reports.  That’s exactly what AddThis and Google Analytics integration does.

Add Google Analytics AddThis Integration

You don’t need anything fancy in Google Analytics.

  1. Create an account at AddThis
  2. Get your code
  3. Add following lines of code within your add this code
  4. <script type=”text/javascript”>
    var addthis_config = {
    data_ga_property: ‘UA-XXXXXXX-X’,
    data_ga_social : true
    };
    </script>

 

Here is full sample code:

 

<!– Google Analytics BEGIN –>
<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-x']);
_gaq.push(['_trackPageview']);

(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 END –>

<!– AddThis Button BEGIN –>
<a href=”http://addthis.com/bookmark.php?v=250″>
<img src=”http://s7.addthis.com/static/btn/v2/lg-share-en.gif” width=”125″ height=”16″ alt=”Bookmark and Share” style=”border:0″/>
</a>

<script type=”text/javascript”>
var addthis_config = {
data_ga_property: ‘UA-xxxxxx-x’,
data_ga_social: true
};
</script>
<script type=”text/javascript” src=”http://s7.addthis.com/js/250/addthis_widget.js#pubid=gapremium”></script>

<!-- AddThis Button END -->

Here is what you will see in Google Analytics





How to Exclude Internal Traffic from Google Analytics

There are two ways to exclude internal traffic from Google Analytics

  1. Using IP address or range of IP addresses
  2. Using a custom variable and cookie when internal IP addresses are dynamic or not-known

To exclude traffic by IP address

There are two ways to do it

  1. Using a “Predefined” filter which has options to Exclude Traffic
  2. Using a Custom filter

1. Using a “Predefined” filter which has options to Exclude Traffic

Choose the options as shown below

  • Predefined Filter
  • Exclude
  • Traffic from the IP Addresses
  • That are equal to
  • Enter the value of IP address
  • Provide a name to filter and save it.

 

Note: In this case you need to enter the exact IP address else it won’t work.  Since you cannot enter any partial IP address, only “that are equal to option”

If you really want to use “ Begins with”, “Contains” , “End With” or IP address range then go over to “Custom Filter” or click on IPV6 option that allows you to enter regular expressions.

 

2. Using Custom Filter

In the filter opinion, choose “Custom Filter” instead of predefined.

On Custom Filter tab, choose following options

  • Exclude
  • Visitor IP address
  • Enter the IP you want to exclude or the range as specified by a Regular Expression
  • Name your Filter and save it

 

 

Note: Google has a tool to help you build a regular expression if needed

http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55572

 

 

To Exclude Traffic by custom variable or cookie
How to Exclude Internal Traffic from Google Analytics when Internal IP Address is Dynamic

How to Exclude Internal Traffic from Google Analytics when Internal IP Address is Dynamic

Google Analytics has a build in filter that allows you to traffic from an IP address. It works fine when you have a static IP but when the IP is dynamic is does not work (If you are not familiar with how IP filtering works then I will write about it later). In this post I will explain how to exclude internal traffic using a method other than IP address

Use Custom Filter

Custom filter allows to exclude traffic by Cookie Content set via setVar.

To exclude traffic from dynamic IP addresses, you can use a JavaScript function to set a cookie on all internal computers and browsers. You’ll then need to create a filter to exclude any traffic that has that cookie set.

How to exclude traffic by cookie:

  1. Create a new page on your site that sets the Custom Variable (User Defined) value in a cookie. The way you do is as follows<body onLoad=”javascript: gaq.push(['_setVar', 'Exclude']);”> – Note this code is in addition to your Google Analytics tracking code on your page
  2.  Let’s call this page do-not-track-me.html
  3.  Visit http://www.yourdomian.com/do-not-track-me.html page from all computers and browsers that you would like to exclude the traffic from i.e. all your internal computers and browsers. (Once set, you can check this value by looking at _utmv cookie on your computer)
  4. Create an Exclude filter to remove data from visitors with this customer variable value:

Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: Exclude
Case Sensitive: No

Note: If at any point you override the cookie or delete the cookie, your traffic will no longer be excluded.

_utmb Google Analytics Cookie Demystified

In this post I will explain _utmb  cookie, one of the many cookie Google Analytics uses.  This cookie is used to track the customer variable that you set in your code.  _utmb is a session cookie and is removed at the end of the session.

_utmb cookie consists of four parts separated by “.”

1. A hash key that identifies the domain and is unique for each domain

2. Page Views in that session

3. An identifier to store count of outbound links that have not been tracked yet.  I am still doing more research on it.  You will generally see 10 as the value for this part of the cookie.

4.Timestamp of last time the cookie was set

The final cookie looks like this

[domain identifier].[page views in that session].[outbound link].[timestamp]

Related:

  1. _utma Google Analytics Cookie Demystified
  2. _utmz Google Analytics Cookie Demystified
  3. _utmv Google Analytics Cookie Demystified

What is _utmv Google Analytics Cookie?

In this post I will explain _utmv cookie, one of the many cookies Google Analytics uses. This cookie is used to track the customer variable that you set in your code.

_utmv cookie consists of two parts separated by “.”

  1. A hash key that identifies the domain and is unique for each domain
  2.   Details about the custom variable that you set

The final cookie looks like this
[domain identifier].[User Defined]|[customer variable 1]^[Customer variable2]^….
Custom variable data is separated by = and the values you see in your cookie will be only for visitor level customer variable. You won’t see session level and page level custom variable.

Here is a example of how the cookie looks


133458700.|1=Registered=Yes=1^3=UserID=30666=1^4=Cookie=30666=1

  1. 133458700 is domain hash
  2. User Defined value (set useing _setVar is empty so you see a . followed by |)
  3. 1=Registered=Yes=1 is the 1st variable that was set   You can interpret it as

[custom variable slot]=[customer variable name]=[custom variable value]=[scope of custom variable , 1 means visitor level custom variable]
Similarly
3=UserID=30666=1 is the 2nd variable that was set
4=Cookie=30666=1 is the 3rd variable that was set

Related:

  1. _utma Google Analytics Cookie Demystified
  2. _utmz Google Analytics Cookie Demystified

_utmz Google Analytics Cookie Demystified

Google Analytic drops few cookies that help them produce the nice reports that you in Google Analytics.  One of those cookies is _umtz.  This cookie is used to determine the sources visitor used to visit your site   Below is an explanation of this cookie.

_utmz cookie consists of  5 parts separated by “.”

  1. A hash key that identifies the domain and is unique for each domain
  2. Timestamp of the visit via that source
  3. Total visits by the visitor
  4. Total number of sources the visitor has come from over the life of the cookie
  5. Details about the source (campaign, source, medium, content, keyword)

The final cookie looks like this

[domain identifier].[unique visitor id].[timstamp when cookie is set].[number of visits].[number of sources visitor has used to visit the site].[details about the source]

Details about the source:  All the variables that you can set in a campaign are set in this part of the cookie (see the image below, I will write more about campaigns in a future post)

Note: Cookie is set every time a visitor uses a new source to If a cookie is already set with value then direct visit won’t overwrite it.

Related: _utma Google Analytics Cookie Demystified

_utma Google Analytics Cookie Demystified

As I wrote in my previous article, Google Analytic drops few cookies that helps it produce the nice reports that you in Google Analytics interface. One of those cookies is _umta. This cookie is used to determine the unique visitor, visit count and recency. Below is an explanation of this cookie.

_utma cookie consists of 6 parts separated by “.”

  • A hash key that identifies the domain an is unique for each domain.
  • Unique visitor id
  • Timestamp of the first visit of that visitor
  • Timestamp of the previous visit – the one that preceded the current one
  • Timestamp of the current visit
  • Total visits by the visitor

The final cookie looks like this

[domain identifier].[unique visitor id].[timstamp of first visit].[timestamp of previous visit].[timestamp of current visit].[total visits]

See the figure below to see the final output

What Cookies Does Google Analytics Use?

Google Analytics uses few cookies to build all the cool reports that you see in Google Analytics. In this post I will show you what those cookies are

  • _utma
    This is written the first time visitor visits the site. Updated with each visit.
    Use: Helps identify the unique visitors. I will provide more information on this cookie in future post.
    Expires: 2 years from last update
  • _utmb
    Session cookie that is update with each page view or event.
    Use: This cookie is used to establish and continue a user session with your site
    Expire: 30 mins after the last update/visitor inactivity
  • _utmz
    This cookie stores the type of referral used by the visitor to reach the site. The cookie is updated with each page view.
    Use: It is used to calculate traffic drivers e.g. search engine traffic, ad campaigns and navigation within the site
    Expires: 6 months from set/update
  • _utmv
    This cookie stores the custom variable information that you set in your code.
    Uses: It is used to set and pass custom variable information to Google Analytics server.
    Expires: 2 years from set/update
  • _utmx
    This is a Google Website Optimizer (GWO) cookie and won’t show up if the site is not using GWO.
    Uses: The cookie stores the variation a particular visitor is assigned to for each experiment, so that the visitor continues to see same variation in each his/her visit.
    Expires: 2 years from set/update