We’ve all seen websites with hotel reservations, affiliate marketing, and webinar signups where in order to make a purchase or become a lead, a visitor needs to go to a third-party page. Well, I have worked with a few like that and in every case tracking is the first thing that needs to be addressed. After all, if we do not know how many people completed the CTA, how could we claim that the campaign is a success?
This kind of tracking has an undeserved reputation of being difficult to implement. But in reality, all you need is Google Analytics code on your site and a little bit (honestly!) of coding.
But before you get started, do yourself a favor and check the following:
1. Make sure you are using the newer version of GA on your site. The on-page script I am using will not work with old Urchin code.
2. If your site is in PHP, GA’s new code may have a syntax conflict. This does not mean you can’t use the new code. It just means that you need to modify it to be
<script src=”http://www.google-analytics.com/ga.js“type=”text/javascript”>
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-XXXXXXX-X”);
pageTracker._trackPageview();
</script>
3. Make sure you have access to your website and can make code changes (DUH!).
Now, you are ready to get started.
Step 1. Set up the goal.
Let’s say, the goal is to track when a user clicks on your RSS subscribe button. Note: when they click on the button, there’s no guarantee that they’ll actually subscribe. Let’s also assume that at www.example.com we have just one type of subscription and it is a big RSS button in the upper right.
1. GA Settings Page is your first stop. Click “Edit” for www.example.com.
From the Conversion Goals and Funnel table, click “Edit” next to one of the not configured Goals.
- Now, set the URL of the goal to be a non-existent page. For example: http://www.example.com/goal/example.
- Name your goal something like “RSS subscription”.
- Use head match as your match type.
- Done
Step 2. Tracking the clicks on the RSS button.
This is the part where you will be coding (just a little bit) and adding a javascript to track the onclick event on the RSS button. To track the button clicks, we need GA to register a “visit” to the fake page we created (http://www.example.com/goal/example).
Now, we need to add the on-click tracking code to the RSS button. This is the code to use:
<a href=”/goal/example” onclick=”javascript:pageTracker._trackPageview (‘example’);”target=”blank”>
Step 3. Looking at your data.
Note: it may take time for the data to show so do not get discouraged if you are not seeing it within the first 72 hours.
You should see your RSS button clicks as a goal you set up:
Enjoy!
Frank
This is great info.
Many marketers are not aware that button clicks can be tracked so this will help many of them.
xman
Will this method work on a Submit button?
Ruth
It should work on any clickable button.
Billy
Thanks for the great info! i never thought it would be as simple as this ^^,
Bente
This may be a stupid question – but can the on-click tracking code …be put directly in the html?
I work as a web editor in a cms, so I don´t do the coding, I only have access to the html on the content (text/pictures) that I myself put up.
I want to track clicks on a button that leads out of the site.
Shaun
Is there any way to track button submissions without using Google Analytics?
Cyril Celestine
This is awesome information.
Google analytic tracking codes have changed since 2010.
Anyway we could get some updated code versions?
Please?
Matthew
We just built a website that sends visitors to a third party site in order to complete the sign up process. Is there anyone you would recommend to have this done to our site by and what you you expect to pay?
Nadeem Siddiqui
Hi, thank for the post it really helped. I have one question is it possible to track button click without setting up a goal. since there is a high frequency of customer on the website so i have to setup goal for each customer. Is there a way to track button click without goals. Please reply thanks
VP
Hey,
I have a website and there is button labelled “zip code”. Is it possible to capture data ( meaning zip codes) user enters there ?
If yes, please provide me more inputs.
Thanks,
VP
royal
yes you can track button without setting up a goal, all you need to do is put this code to the page.
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-XXXXXXX-1’]);
_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);
})();
Nishadha
Some great info, are the codes mentioned still valid. One of the things mentioned about new analytics is that it was going to be easy to track these thing without developers getting involved to add/remove code. Is there a better workaround now ?
Jamie
Hi
Can you tell me do we need to set up a false page for each button we want to track?
Thanks
Jamie
James
Hi – I’m very new to this and am trying to work out if this is the same result that you can achieve with Google Tag Manager, or if this is something different. Can you help?
Marco
Hello,
it is a very interesting way to get around.
I am actually using a Leadpage where a button click is linked to an external website. I cannot add code to the button but I can add Javascript code in the body of the page create an event handler as you described.
Any suggestion how to do it? sample code?
Thank you
Michael Walkling
Hello,
I’m struggling to get my head around the ‘fake page’ idea.
We are creating a link to a page that does not exist? Surely clicking that link will then end in 404.
I am missing something here, but cannot work out what it is.
Can anyone please help me? Thank you.
Michael
Thanks for this. It was easy to implement, once it’s live I’ll check to see if its working!
Betty
This plugins are very good but i prefer to use Google Analytics Counter Tracker plugin on WordPress. It is Very simple and easy to use.You can
Connect your Google Analytics account and get Google Analytics stats;
Group stats by hour, day, month and year.
Neil Greenhalgh
Betty, using that Plugin is all well and good, but you still need to use this code to track the button click as a goal in Analytics.
This article is really old now, but same idea still works a treat thanks.
Uniweb
Good article. But I think you need to update it. Old analytics isn’t support now.
Please update it for Universal Analytics
Vipul Baldaniya
Really great tips….many people are not aware about this button tracking.
Thanks ….Keep it up
Colin Jones
I am trying to implement button tracking on my website, I hope this technique helps.
Raju Mahanta
May i know where i get the GA Settings Page ?
Sean Van Guilder
Hi Raju,
When logged into Google Analytics, you’ll see at the bottom left-hand corner “Admin”.