WWW Matthewedgar Net Easy-Way-Track-Clicks
WWW Matthewedgar Net Easy-Way-Track-Clicks
Matthew
Edgar Jul 17, 2017
One of the key questions to answer about your website is what do people do when they
visit your website? What pages are they looking at? Do they convert? Do they engage?
Home
And one of the key types of engagement is the click or the tap. As part of needing to
About know what people do, you need to know what they click or tap on.
There is a great open source script that goes a long way toward tracking this. By default,
Speaking
this script automatically adds event tracking to every outgoing link, jump link,
downloaded files, email links, and phone calls links. This is a tremendous start and with
Books
a few small tweaks, we can get even more information.
Blog
Knowing which links people clicked on lets you dig deeper into the experience people
have on your website and what is drawing their interest the most. For instance, you
Elsewhere Online might have two links to your contact page—a key conversion point—with one link saying
Elementive “Contact us now” and the other saying “Get in touch to place your order.” Beyond
Matthew on Amazon knowing that people visited the contact page, you want to know which link gets your
Matthew on O’Reilly visitors to the contact page.
Matthew on LinkedIn
To track internal links, you want to modify the script above to add an extra conditional
to detect internal links and we’ll call this event category “Internal Links.” Then, as with
the other link types already included in this script, set the action to the link itself, and the
event label to the page the click happened on and the text to the text of the link. We’ll
set the variable of “track” to true so it actually tracks.
/* internal link */
evAction = el.href;
track = true;
The easiest way I’ve found to tweak this is to get the chain of class names leading up to
this element using something link jQuery code below. If your website doesn’t use jQuery,
then this will require some modification. After getting the CSS chain, it adds it to an
event label.
.map(function() {
if (this.className) {
} else {
return this.tagName;
})
.get()
.join( "," );
With this script in place, you can then differentiate the links by adding a unique class in
the element that contains the link. So, back to the example of two “Download PDF” links,
maybe the first one is contained in a paragraph tag and I add the class name of “top-
pdf-link” to that paragraph tag and the span tag containing the lower “Download PDF”
gets the class of “bottom-pdf-link”. With that in place, I would then know which link is
which when looking at the Event Labels in Google Analytics.
Tracking the time request the use of a timer. Ideally, you can use a JavaScript timer that
PDF created on https://www.htm2pdf.co.uk via the HTML to PDF API
factors in visibility so that you can determine the time people actively spend on the page
(instead of just leaving the website open in a background tab). This code snippet below
assumes that there is a timer already running and the current time value is returned
from a function called getActiveTime().
This adds the click time to the event label (which already includes the page, the link text,
and the CSS chain—give all the information in here, it will take some parsing in Excel to
make it easier to find all the values). With this, you can get an average for how long it
takes people to click on all links on a page, how long it takes to click certain types of
links, and more so that you have a deeper understanding of the click or tap experience,
link-by-link.
Related Posts
Advanced Google Analytics Event Tracking
What Goals To Track
What Is Google Analytics & How Does It Work?