25 useful Google Analytics tips and tricks
Google Analytics is very powerful free tool to track your site visitors and get enormous amount of useful data. To get the most out of Google Analytics use these how to, hacks and tricks. It will help you to improve Google Analytics tracking features and get custom reports and track everything that you want. You’ll find here how to improve Adsense and Adwords data tracking, how to track Twitter and Facebook campaigns, how to get SEO rankings and many other invaluable things to improve your Google Analytics experience.
How to Get Detailed PPC Keyword Data
How to track Twitter/Facebook campaigns with Google Analytics
How to use Google Analytics on intranet sites without domain name
How to create Conversion Goals
How to use Funnels
How to track goals with no associated URL
How to track Goals value for E-Commerce sites
How to track Google Adsense Clicks
How to make Google Analytics Show Real Time Data
How to track iPhones’ visitors
How to track custom visitor segments
How to use Google Analytics without JavaScript
How to track Google Image search with Google Analytics
How to track SEO rankings with Google Analytics
How to track initial referral on redirected pages
How to track outbound clicks with jQuery and Google Analytics
How to track Flash in Google Analytics
How to track site search without keyword in URL
How to use Asynchronous Tracking to improve site performance
How to stop Google Analytics from tracking your own visits
How to export Google Analytics reports with more than 500 records
How to track social networks traffic in Google Analytics
How to make visible Google Analytics Counter
How to track Universal Search traffic with Google Analytics
How to speed up Google Analytics
How to Get Detailed PPC Keyword Data
If a visitor searches for “macbook pro 17” and you have an ad configured for the keywords “macbook pro” as a Broad Match in Google AdWords, then this search will show your ad. But in your GA reports, the keywords for this search will be reported as “macbook pro“.
Using this hack you’ll get detailed report about actual term visitor used to get to your site not just what you have configured for the keywords as a Broad Match in Google AdWords. It will help you refine your keyword triggers.
You need to set up two filters with the following settings:
1. Name: Detailed PPC1
Type: Custom filter – Advanced
Field A -> Extract A: Referral > (\?|&)(q|p)=([^&]*)
Field B -> Extract B: Campaign Medium > cpc|ppc
Output To -> Constructor: Custom Field 1 > $A3
2. Name: Detailed PPC2
Type: Custom filter – Advanced
Field A -> Extract A: Custom Field 1 > (.*)
Field B -> Extract B: Campaign Term > (.*)
Output To -> Constructor: Campaign Term > $B1, ($A1)
Create a new profile to keep the detailed keyword data in a separate profile or apply these filters (Detailed PPC1, then Detailed PPC2) to your main profile. Detailed Search Term data will show up in Keywords section.
How to track Twitter/Facebook campaigns with Google Analytics
To track tweets with Google Analytics you’ll need to add campaign information to your URL before you shorten it with Bit.ly or other URL shortener.
This trick will track anyone visiting the site as a result of your tweet, regardless of where they clicked on the URL, i.e. you will still know that visitor come from your Twitter campaign even the link is forwarded and clicked in email client.
For example, I paste this link into Bit.ly
https://garmahis.com/tips/how-to-use-dropbox-as-free-web-hosting/?utm_campaign=blog&utm_source=twitter&utm_medium=micro-blog
and now it looks like http://bit.ly/bE5EqD
Using this trick you’ll get detailed stat right in the Google Analytics reports. To make it easier, you can use Google Analytics URL Builder and read more about How do I tag my links?
How to use Google Analytics on intranet sites without domain name
It is possible to track Intranet sites with Google Analytics. Once Google Analytics detects the tracking code on a public site, it will record all visits/page views it receives. The trick is, the profile must be detected outside (perhaps on your public website) first, for at least one day. To use GA on your intranet without a domain name, the only trick is to use setDomainName(“none”) in tracking script.
For example:
[js]
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXX-1");
pageTracker._setDomainName("none");
pageTracker._trackPageview();
} catch(err) {}
</script>
[/js]
How to create Conversion Goals
Goals are visitor actions on your website. For example, Sign up for newsletter or Made a purchase or Free trial download. So how Google Analytics tracks Goals? You need to define page URLs which mean certain Goals. For example, signup.html for Sign up for newsletter goal or freetrial.html for Free trial download. When visitor load GA script on these pages it show up in your Goals stat.
So to set up a Goal in Google Analytics you’ll need.
1. Click the “Edit” link on the Google Analytics Website Profiles page.
2. Click the “Edit” link in the “Settings” column for the first goal (i.e. G1).
3. Check Active Goal On., fill in Goal URL (which should be just page URL without domain name), Match Type: choose Exact match if you website don’t use any parameters in URL, choose Head Match if it uses dynamically generated content. Goal Name: Can be anything meaningful for you. You can read more about What is the difference between head, Exact, and Regular Expression Match? on Google Analytics help page.
A funnel is the series of pages that a visitor passes through to accomplish a goal. For example, adding to cart, checkout, shipping. The point of tracking funnels is to know how many people start the conversion process, but don’t finish it. You need to fill out Define Funnel page with Goal URLs in the exact order visitor follows them: addtocart.html, checkout.html, shipping.html After you defined Funnels you’ll get Abandoned Funnels report as well as Funnel Visualization in your Google Analytics dashboard.
How to track goals with no associated URL
As soon as goals are just pageviews set to be a goal inside GA, to track a goal without a specific pageviews you need to simulate pageviews using JavaScript. This hack can be useful to track software downloads or registration form submission without unique page.
After you set up your Goal, pick Exact Match, and any name as Goal URL, starting with the slash, (/) no spaces.
For example, /trialdownload
To finish with it you just need to add some JavaScript code to the link you want to track. It should contain the Goal URL name you previously used.
[html]<a href="trial.zip" onclick="pageTracker._trackPageview(‘/trialdownload’)"> Download Trial</a>[/html]
How to track Goals value for E-Commerce sites
You can track income from Goals with Google Analytics. It’s mostly useful for those selling some products on their website. For example, you have a store selling 10$ eBooks. All you need to do is set 10$ as your Goal value. If the value of your Goals is unknown (you sell different number of products with variable pricing) then follow these steps.
1. Set up your website profile as E-Commerce website. Go to Profile Settings and check radio button ‘Yes, an E-Commerce site’.
2. Set Goal value as 0 (it will be dynamically created later).
3. You need to call some JavaScript to register the sale with GA. The parameters for these functions are outlined in the example below provided by Google. You need to populate in the values for each of those items when the page is rendered. In the event that you don’t have a value like, for shipping you can put 0, or leave it blank.
[js]
<script type="text/javascript">
pageTracker._addTrans(
"1234", // Order ID
"Mountain View", // Affiliation
"11.99", // Total
"1.29", // Tax
"5", // Shipping
"San Jose", // City
"California", // State
"USA" // Country
);
pageTracker._addItem(
"1234", // Order ID
"DD44", // SKU
"T-Shirt", // Product Name
"Green Medium", // Category
"11.99", // Price
"1" // Quantity
);
pageTracker._trackTrans();
</script [/js]
How to track Google Adsense Clicks
Google Analytics tracking your clicks can help you to optimize your site, not just for CTR, but for the type of visitors that click Adsense ads. This is the script to track your Adsense clicks.
The tracking is done through “Goals”. To set up Google AdSence tracking:
1. Create a goal, In the Goal URL field, enter “/asclick” and “AdClick” for the goal name.
2. Copy the script to your website server and add the following to the footer of your website after all Adsense code.
script
[js]function as_click () {
urchinTracker (‘/asclick’);
}
// incredibly funky onload add-event scripting, for all browsers
if(typeof window.addEventListener != ‘undefined’)
{
//.. gecko, safari, konqueror and standard
window.addEventListener(‘load’, adsense_init, false);
}
else if(typeof document.addEventListener != ‘undefined’)
{
//.. opera 7
document.addEventListener(‘load’, adsense_init, false);
}
else if(typeof window.attachEvent != ‘undefined’)
{
//.. win/ie
window.attachEvent(‘onload’, adsense_init);
}
//** remove this condition to degrade older browsers
else
{
//.. mac/ie5 and anything else that gets this far
//if there’s an existing onload function
if(typeof window.onload == ‘function’)
{
//store it
var existing = onload;
//add new onload handler
window.onload = function()
{
//call existing onload function
existing();
//call adsense_init onload function
adsense_init();
};
}
else
{
//setup onload function
window.onload = adsense_init;
}
}
function adsense_init () {
if (document.all) { //ie
var el = document.getElementsByTagName("iframe");
for(var i = 0; i < el.length; i++) {
if(el[i].src.indexOf(‘googlesyndication.com’) > -1) {
el[i].onfocus = as_click;
}
}
} else { // firefox
window.addEventListener(‘beforeunload’, doPageExit, false);
window.addEventListener(‘mousemove’, getMouse, true);
}
}
//for firefox
var px;
var py;
function getMouse(e) {
px=e.pageX;
py=e.clientY;
}
function findY(obj) {
var y = 0;
while (obj) {
y += obj.offsetTop;
obj = obj.offsetParent;
}
return(y);
}
function findX(obj) {
var x = 0;
while (obj) {
x += obj.offsetLeft;
obj = obj.offsetParent;
}
return(x);
}
function doPageExit(e) {
ad = document.getElementsByTagName("iframe");
for (i=0; i<ad.length; i++) {
var adLeft = findX(ad[i]);
var adTop = findY(ad[i]);
var inFrameX = (px > (adLeft – 10) && px < (parseInt(adLeft) + parseInt(ad[i].width) + 15));
var inFrameY = (py > (adTop – 10) && py < (parseInt(adTop) + parseInt(ad[i].height) + 10));
if (inFrameY && inFrameX) {
urchinTracker(‘/asclick’);
}
}
}
//end for firefox
[/js]
[js]
code
<script src="/astrack.js" type="text/javascript"></script>[/js]
How to make Google Analytics Show Real Time Data
By default Google Analytics reports every 24 hours. To see real time reports (well, actually with 1-2 hours delay) find the date range feature on your GA page (below the right top “My analytics Accounts”) and set current date for reports.
How to track iPhones’ visitors
You can track iPhone visitors by adding a default Advanced Segment showing just visits from iPhones. To set up iPhone tracking, click on the drop down menu at the top right of any report next to the text “Advanced Segments”, and select “Visits from iPhones” in the list of default segments. Google Mobile blog has more on Iphone tracking.
How to track custom visitor segments
In addition to segmenting users along pre-defined segments such as geographic region and language preference, Google Analytics allows you to define custom segments and analyze the behavior of each segment. For example, you might want to segment visitors according to the members vs non-members on a site that has a member login, gender or income (based on the user providing you data). You could then analyze browsing and buying behavior based upon the selected job categories.
Most typically, custom segments are set by client-side or server-side logic that sets the variable depending on the page being visited, or as a result of a selection on the part of the visitor, such as logging in.
To create custom segments, insert the following code below the Google Analytics tracking code:
[js]<script type=”text/javascript”>__utmSetVar(’NotLoggedIn’);</script>[/js]
on pages displayed for non logged in visitors and
[js]<script type=”text/javascript”>__utmSetVar(’LoggedIn’);</script> [/js]
on pages for logged in visitors. Read more about Custom Visitor Segments.
How to use Google Analytics without JavaScript
It’s possible to use Google Analytics without JavaScript which makes possible to measure data like RSS, podcasts, image or pdf visits. You can also use it as a replacement for the regular Google Analytics scripts on your pages. There’s a few ways to do it.
Using no JavaScript tracker
This script uses php, and the server-side functions which might be different for html/asp/cfm sites.
[php]
<?php
$var_utmac = ‘UA-xxxx-3’;
$var_utmhn = ‘YOUR-DOMAIN.com’; // domain
$var_utmn = rand(1000000000,9999999999); // random number
$var_cookie = rand(10000000,99999999); //random cookie number
$var_random = rand(1000000000,2147483647); //number under 2147483647
$var_today = time();
$var_referer = $_SERVER[‘HTTP_REFERER’]; //referer url
if ($var_referer == ”) { $var_referer = ‘-‘; }
$var_uservar=’-‘; // no user-defined
$var_utmp=’/nojs_tracker’ . $_SERVER[‘REQUEST_URI’]; // folder called no_jstracker to segment nojavascript visitors
$urchinUrl=’http://www.google-analytics.com/__utm.gif?utmwv=3&utmn=’ . $var_utmn . ‘&utme=&utmcs=-&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn=’ . $var_utmhn . ‘&utmhid=’ . $var_utmn . ‘&utmr=’ . $var_referer . ‘&utmp=’ . $var_utmp . ‘&utmac=’ . $var_utmac . ‘&utmcc=__utma%3D’ . $var_cookie . ‘.’ . $var_random . ‘.’ . $var_today . ‘.’ . $var_today . ‘.’ . $var_today . ‘.2%3B%2B__utmz%3D’ . $var_cookie . ‘.’ . $var_today . ‘.2.2.utmcsr%3D_SOURCE_%7Cutmccn%3D_CAMPAIGN_%7Cutmcmd%3D_MEDIUM_%7Cutmctr%3D_KEYWORD_%7Cutmcct%3D_CONTENT_%3B%2B__utmv%3D’ . $var_cookie . ‘.’ . $var_uservar . ‘%3B’;
echo ‘ <img src="’ . $urchinUrl . ‘" border="0" />’;
?>
[/php]
Using Galvanize PHP class
You need to use this code. The PHP class itself could be downloaded from Sourceforge Project Page
[js]include(‘Galvanize.php’);
$GA = new Galvanize(‘UA-XXXXX-XX’);
$GA->trackPageView();[/js]
How to track Google Image search with Google Analytics
Google Image search gives you referral URL’s that aren’t really readable. Since Google Analytics can’t read that, it doesn’t get the keyword out of it. However, it’s possible to track Google Image search keywords with some JavaScript enhancements. Add this below your Google Analytics tracking code.
[js]<script type="text/javascript" charset="utf-8"
var pageTracker = _gat._getTracker("YOUR TRACKER ID");
var refferer = document.referrer;
if (refferer.search(/images.google/) != -1 && refferer.search(/prev/) != -1) {
var regex = new RegExp("images.google.([^\/]+).*&prev=([^&]+)");
var match = regex.exec(refferer);
pageTracker._setReferrerOverride("http://images.google." + match[1] + unescape(match[2]));
}
pageTracker._trackPageview();
</script>
[/js]
How to track SEO rankings with Google Analytics
Google Analytics shows by default which terms brought visitors to your site via the search engines. However, Google Analytics does not include where that keyword ranked as part of the display. However, it’s capable of tracking the exact clicked position.
To track Seo rankings, create a new profile and new filter:
Filter name: “Ranking”
Filter type: “Custom filter – Advanced”
Field A -> Extract A: Referral, ^https?://www\.google\.(com|ca)/(?!custom|m/).*[?#&]cd=([^&]+).*&q=([^&]+)
Field B -> Extract B: Medium:^organic$
Output To -> User Defined: $A4 (position: $A3)
How to track initial referral on redirected pages
The original referrer data is lost because of the JavaScript redirect used on landing pages or A/B testing in Website Optimizer. This means that the traffic source will be wrong. Google Analytics has a way to overwrite the referrer data.
Change original GA tracking code to this:
[js]<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-11");
pageTracker._initData();
</script>[/js]
How to track outbound clicks with jQuery and Google Analytics
With Google Analytics it’s possible to manually track clicks by adding an onClick attribute in the anchor tag. jQuery will help to do it much easier.
Add this code below Google Analytics tracker insertion code:
[js]
$(document).ready(function(){
var localserver = "www.yourdomainname.com";
$("a").not(".kLink").not("a[href^=’http://"+localserver+"’]").click(function(){
$(this).attr("target", "blank");
var url = $(this).attr("href").replace(/^http\:\/\/(www\.)*/i, "");
pageTracker._trackPageview(‘/external/’+url);
});
});[/js]
How to track Flash in Google Analytics
The Google Analytics Tracking for Adobe Flash component makes it easy to implement Google Analytics in Flash content. This component, developed by Adobe contains all of the functionality of the Google Analytics JavaScript code. The Flash Tracking component is a compiled tracking object native to ActionScript 3, making Analytics implementation intuitive in Flash, and Flex development environments.
How to track site search without keyword in URL
Google Site Search tracking requires that your site search keyword is contained in your URL. It’s possible to track site search with Google Analytics without keyword in URL.
1. Add the following line of code to your existing Google Analytics tracking code:
[js]pageTracker._trackPageview(‘/search?q=[keyword]’);[/js]
2. Now you need to replace [keyword] with the actual keyword being searched for. For PHP platform it will be something like this:
[php]pageTracker._trackPageview(‘/search?q=<?php echo $keyword; ?>’);[/php]
3. Put ‘q’ into the “Query Paramater” box in the Site Search section in your Google Analytics profile
How to use Asynchronous Tracking to improve site performance
Asynchronous Tracking is an alternative way to track website visitors with Google Analytics. Asynchronous tracking optimizes how browsers load ga.js so its impact on user experience is minimized. It also allows you to put your Analytics snippet higher in the page without delaying subsequent content from rendering.
[js]<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-XXXXX-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’;
(document.getElementsByTagName(‘head’)[0] || document.getElementsByTagName(‘body’)[0]).appendChild(ga);
})();
</script>[/js]
How to stop Google Analytics from tracking your own visits
It’s important to have Google Analytics exclude your own visits to your sites in order to get a true data of your sites visitors. To solve this issue you need to set a cookie on your browser and then use Analytics’ filter to ignore visits from all machines that has this cookie set.
1. Add this code to the site page which visitors to your site have not access and then just visit this page to set the cookie.
[js]<body onLoad=”javascript:pageTracker._setVar(‘c1902489’)”>[/js]
2. Create a new filter with the following settings:
Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: c1902489 (your cookie name)
Case Sensitive: No
How to export Google Analytics reports with more than 500 records
The maximum number of records for export in Google Analytics is limited to 500. If you need to export more records, simple URL hack will help you.
Look for this string in the address bar of your browser & limit = 500 and change it to any number you need. Then choose Export data format from drop down menu.
How to track social networks traffic in Google Analytics
Social media marketing play such a role these days, that analyzing of its effectiveness is becoming very important. Google Analytics can analyze traffic mediums such as direct, organic. Using this hack you’ll be able to add social networks as a separate traffic medium.
1. Head to ‘Advanced Segments’ in your main Google Analytics profile
2. Create a new segment and drag the ‘source’ box which under ‘Traffic sources’ to ‘dimension or metric’ window
3. Open the ‘Condition’ drop down and under ” paste the following sources:
[text]
digg|aim|friendfeed|econsultancy|blinklist|fark|furl|misterwongs|wikipedia|stumbleupon|netvibes|bloglines|linkedin|facebook|del\.icio\.us|feedburner|
twitter|technorati|faves\.com|newsgator|PRweb|msplinks|myspace|bit\.ly|tr\.im|cli\.gs|zi\.ma|poprl|tinyurl [/text]
How to make visible Google Analytics Counter
Google Analytics counter can be used in the same way as Feed Count to display the number of subscribers for a feed or TwitterCounter to display your Twitter followers. To create dynamic Google Analytics Counter that can display your website’s statistics like pageviews, visits, etc. you need PHP class named GAPI
You should fill in 3 variables to use GAPI:
- Google Analytics user that has access to the website stats to be displayed. For security reasons you should add new user for this purpose and provide only read access to website’s data.
- Google Analytics user password.
- Profile ID of the website (it is ID that appears on browser’s address bar when a report of the website is clicked).
Insert these variables into this code:
[php]
<?php
define(‘ga_email’,’yourGoogleEmail’);
define(‘ga_password’,’yourGooglePass’);
define(‘ga_profile_id’,’yourProfileID’);
require ‘gapi.class.php’;
$ga = new gapi(ga_email,ga_password);
$ga->requestReportData(ga_profile_id,array(‘browser’,’browserVersion’),array(‘pageviews’));
?>
[/php]
Here’s also HTML and CSS to set up Google Analytics counter.
[html]<div id="statsWrap">
<div id="statsDetailsWrap">
<div id="statsCount">
<span id="statsPageviews"><?php echo $ga->getPageviews() ?></span>
<span id="statsVisits"><?php echo $ga->getVisits() ?></span>
</div>
<div id="statsMetric">
<span id="statsPageviewsText">pageviews</span>
<span id="statsVisitsText">visits</span>
</div>
</div>
<div id="byGoogle">By Google Analytics</div>
</div>[/html]
[css]#statsWrap {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
}
#statsDetailsWrap {
background: #333333;
float: left;
padding: 1px 3px 1px 1px;
border: #666666 1px inset;
}
#statsCount {
float: left;
padding: 1px 3px;
background: #999999;
color: #FFFFFF;
border: #666666 1px inset;
width: 40px;
height: 12px;
}
#statsMetric {
float: left;
padding: 3px;
color: #FFFFFF;
width: 50px;
height: 12px;
}
#byGoogle {
clear: both;
color: #666666;
font-size: 10px;
}
[/css]
How to track Universal Search traffic with Google Analytics
This hack will help you to know how many people were actually clicking the blended results you see in Universal Search. This can be useful to be know which link was clicked If the search results for a specific key phrase show both images and ‘regular’ text links.
Set up two filters in a new Google Analytics profile:
1.
Create filter for organic traffic
New filter ->
Filter name `Organic`
Filter Type -> Custom Filter
Checked : include
Filter Field: Campaign Medium
Filter Pattern `organic`
2.
Create filter for All Universal Search traffic
New Filter: ‘Universal Search Items
Filter Type: Custom Filter
Checked: Advanced
Field A -> Extract A -> Referral -> (.*)oi=([a-zA-Z_]+)&(.*)
Field B -> Extract B -> Referral -> (\?|&)q=([^&]*)
Output To -> Constructor -> User Defined -> $B2 : $A2
How to speed up Google Analytics
Instead of calling the external http://www.google-analytics.com/ga.js file in your site’s html, you can save the ga.js code and serve it from on your own server. This reduces DNS lookups, gives you control over caching, and if you combine the ga.js with a JavaScript file already on your site you reduce HTTP Requests.
Share This


3 thoughts on “25 useful Google Analytics tips and tricks”