Onclick Tracking is already built into your Google Analytics account, we just need to hook it up to your website. It’s got a lot of benefits, for tracking downloads, specific button clicks (such as how many people click your Logo instead of Home), and other data you may wish to track such as new launches and promotions. It works by placing a small specific piece of code on the links you’d like to track – when they’re (you guessed it) – clicked. To integrate your onclick tracking, make sure your Analytics snippet (above) has this piece of code:
The trackPageview function sets the account up for pushing event data to your Google Analytics account.
So where do we use it? And how? The easiest way to integrate your onclick functionality is inside a hyperlink. You’ll need to pay special attention to the wording you place inside your onclick functions though, as this feeds directly back into Google Analytics and starts churning out results.
The above piece of code is the inline JavaScript that we need to use for tracking, but it needs to be setup correctly in order to get results. You’ll notice the quotation marks near the end are empty, this is because we need to set a few fields for data collecting.
The piece of code below was taken from the Download button from my previous article which includes a Free Download link, you can see it in the flesh here if you Inspect Element on the button (end of the article). So here’s what the inline JavaScript looks like inside the working Download hyperlink:
You’ll notice I’ve populated the end fields (quotations) with the Events that will be pushed back to my Google Analytics account. The sequence is as follows:
Click, CV Pack Download, CV Zip Downloads.
Which really means:
Category, Action, and followed by an Optional Label.
What now?
Copy this snippet of code and use it on any of your hyperlinks:
Inside Analytics
To access the data inside your Analytics Dashboard, simply hit the sidebar tab ‘Content’ followed by ‘Events’ then ‘Overview’, and you can check out the data you’re collecting with your onclick events there, by Event Category, Action or Label. It’s good to put all Clicks inside one category, to stack them up against each other to see which is getting more attention and which isn’t. You’ll notice that Google Analytics automatically takes care of any outbound link-click tracking too.
Notes
Your onclick Tracking doesn’t need to be setup in your Analytics Dashboard, wait a day or so after implementing your JavaScript and you will start to see data being pushed into your account.
Code: Select all
_gaq.push(['_trackPageview']);
The trackPageview function sets the account up for pushing event data to your Google Analytics account.
So where do we use it? And how? The easiest way to integrate your onclick functionality is inside a hyperlink. You’ll need to pay special attention to the wording you place inside your onclick functions though, as this feeds directly back into Google Analytics and starts churning out results.
Code: Select all
onclick="_gaq.push(['_trackEvent', '', '', '']);"
The above piece of code is the inline JavaScript that we need to use for tracking, but it needs to be setup correctly in order to get results. You’ll notice the quotation marks near the end are empty, this is because we need to set a few fields for data collecting.
The piece of code below was taken from the Download button from my previous article which includes a Free Download link, you can see it in the flesh here if you Inspect Element on the button (end of the article). So here’s what the inline JavaScript looks like inside the working Download hyperlink:
Code: Select all
<a href="/downloads/CVDownload.zip" class="download" onclick="_gaq.push(['_trackEvent', 'Click', 'CV Pack Download', 'CV Zip Downloads']);">Download</a>
You’ll notice I’ve populated the end fields (quotations) with the Events that will be pushed back to my Google Analytics account. The sequence is as follows:
Click, CV Pack Download, CV Zip Downloads.
Which really means:
Category, Action, and followed by an Optional Label.
What now?
Copy this snippet of code and use it on any of your hyperlinks:
Code: Select all
<a href="" onclick="_gaq.push(['_trackEvent', 'Category', 'Action', 'Extra Label if you like!']);">Click here!</a>
Inside Analytics
To access the data inside your Analytics Dashboard, simply hit the sidebar tab ‘Content’ followed by ‘Events’ then ‘Overview’, and you can check out the data you’re collecting with your onclick events there, by Event Category, Action or Label. It’s good to put all Clicks inside one category, to stack them up against each other to see which is getting more attention and which isn’t. You’ll notice that Google Analytics automatically takes care of any outbound link-click tracking too.
Notes
Your onclick Tracking doesn’t need to be setup in your Analytics Dashboard, wait a day or so after implementing your JavaScript and you will start to see data being pushed into your account.
Get full forum access here! || Follow us || Rules || 1 fee, download them all!
Giin70 Said:"im busier than a 3 legged cat on a frozen pond scratching for a place to poop..."
He also Said:"Maybe we can ship yall off to mamby pamby land to look to self confidence, ya jackwagon."
Then"your about as useless as tits on a boar
And:"headspace and keyboard timing issue on end user end"
Always have a back up plan for your back up plan.
My Pc Specs: My Rig!
Giin70 Said:"im busier than a 3 legged cat on a frozen pond scratching for a place to poop..."
He also Said:"Maybe we can ship yall off to mamby pamby land to look to self confidence, ya jackwagon."
Then"your about as useless as tits on a boar
And:"headspace and keyboard timing issue on end user end"
Always have a back up plan for your back up plan.
My Pc Specs: My Rig!