Hello There!

Lorem ipsum dolor sit amet, consectetur adipiscing elit,

 About Riddhi Mehta

Riddhi is an experienced User Experience Designer with a demonstrated history of working in the information technology and services industry. Skilled in Prototyping, Concept Development, Design Thinking, User Experience Design, and Web Design, she has a bachelors in Product Design and a Masters in Communication Design.

External Link Tracking through Google Analytics

Every time when we need to track external links and want to see how many links were clicked with our website. We can track using multiple methods i.e. Google Analytic’s trackEvent or Virtual trackPageview.

We can track third party links using trackEvent function of  Google Analytics. But when it comes to appending all links in dynamically generated pages and in static pages. It becomes head-ache for appending the code and testing if everything works fine with each links.

Implement following javascript code to track external links through Google Analytics accurately. It helps in saving time by elimination of adding external link tracking code manually.

Here’s the snippet of the code:

<!-- include jquery javascript framework -->
<script type='text/javascript' src='http://code.jquery.com/jquery-1.7.min.js'></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']); //set account id

_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);

})();

//code block to attach trackevent code for external links/mailto links

$(document).ready(function(){

// Creating custom :external selector

$.expr[':'].external = function(obj){

return !obj.href.match(/^javascript/) && (obj.hostname != location.hostname);

};

// Add 'external' CSS class to all external links

$('a:external').addClass('external');

$('a.external').click(function(){

var obcat = this.href.match(/^mailto:/);

var targeturl = this.href;

if (obcat){

targeturl = targeturl.replace('mailto:','');

_gaq.push(['_trackEvent', 'Mailto', targeturl , document.location.href,1,true]);

}else{

var targetname = this.text;
var isDoc = this.href.match(/.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|&|?)/);
if (isDoc) {
	_gaq.push(['_trackEvent', 'DocDownlod', targetname, document.location.href,1,true]);
}else{
	_gaq.push(['_trackEvent', 'Outbound', targeturl, document.location.href,1,true]);
}

}

});

$('a').click(function(){
	var targetname = this.text;
	var isDoc = this.href.match(/.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|&|?)/);
	if (isDoc) {
		_gaq.push(['_trackEvent', 'DocDownlod', targetname, document.location.href,1,true]);
	}
});

});

</script>

Explanation of the code:

Jquery Javascript Framework is required to work with it. Though you can also use mootools, prototype javascript framework.

<script type='text/javascript' src='http://code.jquery.com/jquery-1.7.min.js'></script>

We can include the jquery’s library to work with DOM - Javascript

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']); //set account id
_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);
})();

Above code is self explanatory, that includes Google Analytics’s Asynchronous code.

We wrap our function in $(document).ready so that it doesn’t affect page loading process.

//code block to attach trackevent code for external links/mailto links
$(document).ready(function(){
...
...
});

</script>

Then we’ll have to create a custom external selector using a function where it says whether hostname matches with current document’s hostname.

// Creating custom :external selector
$.expr[':'].external = function(obj){
return !obj.href.match(/^javascript/) && (obj.hostname != location.hostname);
};

Then we can append a custom class to all those links which are external links

// Add 'external' CSS class to all external links
$('a:external').addClass('external');

Now we can add a check if the external link is either mailto link or actual 3rd party URL and attach  a click event function for trackEvent

$('a.external').click(function(){
var obcat = this.href.match(/^mailto:/);
var targeturl = this.href;
if (obcat){
targeturl = targeturl.replace('mailto:','');
_gaq.push(['_trackEvent', 'Mailto', targeturl , document.location.href,1,true]);
}else{

var targetname = this.text;
var isDoc = this.href.match(/.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|&|?)/);
if (isDoc) {
	_gaq.push(['_trackEvent', 'DocDownlod', targetname, document.location.href,1,true]);
}else{
	_gaq.push(['_trackEvent', 'Outbound', targeturl, document.location.href,1,true]);
}
}
});

We can check if the current link’s href matches with mailto then fire ‘Mailto’ trackevent, ‘DocDownload’ or ‘Outbound’ trackevent.

Here we’ve added 1 and “true” in the 4th and 5th argument additionally. 5th argument is a new feature which prevents the trackevent call in the calculation of bounce rate.

You can view all these events reported in your GA Interface under

Content > Event Tracking > Categories > Outbound/Mailto/DocDownload

There’s one more usage of appending cookie parameters automatically to all external links and forms. I’ll talk about it next time.

Requirement:

A Jquery Framework (If you are already using a jquery library you don’t need copy jquery library reference)

Script needs to be pasted through all pages of your website, where you want to track external links and mail to links.

Alteration:

You may use virtual trackpageview, instead of trackevent but it’s your choice.

Note:

When you use it with multiple javascript frameworks necessary safeguard needs to be added for the code. If you are using javascript functions to redirect to external links it wouldn’t work.

Online Surveys - Great way to engage & know what customers want

We run huge marketing campaigns to serve our customer better. We use Premium Analytics tools because we don’t want to lose any important insights, the ads are becoming more contextual to target right user for the right product. At the end of the day, it’s the customer who has to be happy with our product or services. What would be a better way than asking them directly?

Surveys help us communicate directly with our customers. What kind of features they want? What turns them off? Do they really need your newsletter?

Online survey is a very important marketing tool to know what customers want, especially what they don’t want. There are a lot of tools available for online surveys.

A good survey tool will let you Create customized questions, and provide detailed responses with results and insights.
We studied a lot of tools and found a few tools very essential and full of features. Theses tools are widely used amongst big brands, and the best part is, they all have a free plan, which is great for small organizations, and also for first timers!

    1. Survey monkey
      • Free plan limit:
      • Surveys: 1
      • Questions: 10
      • Responses: 100
      • At plans starting from $ 19.95 per month, you can get up to 1000 responses. You can even choose $200 per month and get unlimited questions and responses.

Survey monkey is one of the best and most popular tools available.

Our review:

It provides real time results. Important for very large sample size. You can even embed surveys on your web site. You can even customize the template to match the look & feel with your website. You can also send surveys via email and website pop ups, which is a unique feature. Survey monkey is used by many big brands and is considered one of the best survey tools around. It offers a great user-friendliness with a very neat and clean UI. It offers a nice Dashboard to manage your survey campaigns. There’s an analyze section which gives a nice analysis of your survey responses.<a href=” https://tatvic.com/google-analytics-implementation/”>Google Analytics Integration</a> is much easier with Survey monkey. There’s an app available in Google apps marketplace. Which easily integrates with you Google analytics account. You can gather very important insights about your surveys in Google Analytics using this app.

Overall, SurveyMonkey is highly recommended if you need to run a lot of surveys regularly. The highest plan $200 per month is also not a bad price for this product for large users.

    1. Survey gizmo
      • Free plan limit:
        • Surveys: Unlimited
        • Questions: Unlimited
        • Responses: 250
      • All paid plans offer 14-day free trial. So if you are confident about the product, you can even go directly for the paid plan.Plans are from $19 to $159.Our review:

Survey Gizmo

Survey gizmo has a very easy and user-friendly tool. Unlike other tools, you can create unlimited Surveys and ask unlimited questions. At only $19/month you can upgrade to unlimited responses. It’s the best part of this service. It offers a nice dashboard the moment you sign in, to easily manage your survey projects. There’s a smart thing they have done. When you click on Pricing, you can’t see a free plan.

They are hiding the free plan in the Features section. While you are creating the survey, it guides you throughout with examples making it easy even for first-timers. It has a fresh web 2.0 look and user-friendliness, which makes creating and managing surveys a treat. If you send a lot of surveys. With a cool look, it also delivers on the functionality. There’s no app available for Google Analytics implementation, but there’s an easy code pasting method to analyze your survey responses in Google Analytics. The $19 plan provides unlimited responses which is not a deal at all.

    1. Question Pro
      • Free plan limit:
        • Surveys: 1
        • Questions: 10
        • Responses: 100
Our review:

Question Pro

QuestionPro doesn’t live up to look and user-friendliness as much as the above 2 tools do, but it’s no less in terms of functionality. It offers a simple interface with lots of question types. It is also the cheapest tool available. In the $12.50 plan, you get unlimited surveys, questions, and responses. . It also offers Google Analytics integration.

If you are a non-profit organization, you get a license for free. Previously it offered unlimited responses in a free plan, now it offers only 100. QuestionPro’s paid plan is a perfect fit if you are a start-up or a small organization.

Summary:
All of these tools are great fit for different kind of needs. All of them offer Google Analytics integration.

SurveyMonkey is the best choice enterprise. Premium pricing with much more premium features. It offers web pop-up surveys which non of other do, provides 24×7 customer support, real-time responses, and lot many things. Offers great usability and simplicity in creating and managing surveys. It has a great analysis and reporting section, which is very unique among other tools.

Surveygizmo is a little moderate on pricing but still is a very nice choice for medium and even big organizations. It offers Facebook, Twitter, and Mailchimp integration in a free plan as well. Just pay $19 and you can get unlimited responses.

The questioner should be yours if you don’t want to pay $19 per month or are trying out a paid survey application. Pay $12 per month for unlimited responses. You can even go for a $99 plan for advanced features and support. Perfect for small budgets.

Bot Icon
Bot Icon

Tatvic Bot

Explore About Tatvic and Services