AJAX Linktracker Documentation
Installation:
- Upload the file linktracker.js anywhere to your site and remember the URL.
- Upload the folder named linktracker and its content into the modules-folder of your EE system-directory.
- Upload the file named lang.linktracker.php into the /language/english-folder of your EE system-directory.
- In your Control Panel navigate to CP Home › Modules, find the AJAX Linktracker module and click Install.
- Now you have access to the CP Interface of the module. It is here where you can view and reset the click-statistics.
Adding the javascript-snippet to your templates
On every page that may contain links that are to be tracked the java-script call needs to be included. Preferably somewhere at the bottom of the page. If you have a footer-template that may be a good place to put it.
Add the following code to the template/s in question:
<script type="text/javascript" src="http://yourdom.ain/linktracker.js"></script>
<script type="text/javascript">
{exp:linktracker:apiurl}
</script>
Of course you need to replace the URL to the one where you uploaded your copy of linktracker.js.
Usage:
Now all you got to do is to add a unique id-attribute to any link that is supposed to be tracked. This may be links in entries as well as links you compose somehow in your templates with custom fields and the like. External links, internal links, links to files… it doesn’t matter as long as it has and id.
Example:
<a id="holiday-photos" href="http://mydom.ain/pictures.zip">My latest album</a>
This link will show up under the Link ID holiday-photos in the click-statistics.
<a href="http://expressionengine.com/">Great CMS</a>
This link will not be tracked since there’s no id present.
Special IDs
There is a set of IDs that serve a special purpose. If the id starts with either vc1_, vc2_, vc3_ or vc4_ followed by a number it is assumed that the number is an entry_id of a weblog entry.
If a link with such an id is clicked it gets tracked like usual. Additionally the corresponding view_count variable of the weblog entry is incremented by one.
Example:
<a id="vc2_93" href="http://anydom.ain/blog.php"></a>
If this is clicked, view_count_two of the weblog-entry with the entry_id 93 gets incremented.
<a id="vc4_115" href="http://another.dom.ain/index.html"></a>
If this is clicked, view_count_four of the weblog-entry with the entry_id 115 gets incremented.
I think you get the point.
An application example for this is a link directory-type of site where you have a custom field for an outgoing URL. In a template you’d do something like:
{exp:weblog:entries weblog="directory"}
<h2>{title}</h2>
{site_description}
<a id="vc1_{entry_id}" href="{sites_home}">Goto Homepage</a> (Visited {view_count_one} times)
{/exp:weblog:entries}
Then you could use
{exp:weblog:entries weblog="directory" orderby="view_count_one" sort="desc"}
to easily pull out a list of the most popular links in your directory.
Display # of clicks in templates
There’s also a tag that outputs the number of clicks for a given link_id if you don’t utilize the view_count approach. It’s a single tag that doesn’t have a closing element.
{exp:linktracker:clicks link_id="holiday-photos"}
It only has one mandatory parameter which is the link_id=”“ to be displayed.
Click Statistics:
Under CP Home › Modules › AJAX Linktracker you’ll find a list of all Link IDs and their number of clicks. They only show up once they have been clicked for the first time.
To the right there is a Reset-link on every line that resets the counter for the respective Link ID.
If you click on a Link ID you get a detailed listing of every click for that ID.
Questions / bug reports
For general comments, brickbats & bouquets please use the form over here.User Talk
2011-12-15 00:44
Update to EE 2 ?
2010-11-09 21:42
I’ve got this installed on a website that I’d like to upgrade to EE 2. Any chance this module could be updated to work on that install. I’d pay a fee to upgrade.
2010-10-07 17:51
I recently started working for a company whose website was written in EE 1.6.4 (recently upgraded to 1.6.9) and I see the previous developer has made use of AJAX Linktracker to capture what files members have been downloading off the site.
On trying to get my head around how everything works (my PHP skills are quite basic) I noticed that anyone using Firefox or Chrome isn’t captured? I perhaps generalise when I say “anyone” but the handful of testing I did with different browsers yielded that conclusion. Reading the documentation, you state the limitation of it not tracking people whose browsers have javascript disabled - by in my tests, mine was enabled and I still wasn’t picked up.
Is this just a result of browsers having changed over the last few years since this mod was written? Should it still work with these browsers today, or perhaps the last developer made other changes that have caused this to fail? The mod works fine with IE still.
If anyone can offer me any guidance on how my site can track these users using Firefox or Chrome, that would be great.
Cheers, Jay
2010-08-09 18:13
When I install this module and browse to a page with the javascript snippet instructions the browser throws up this error:
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
2010-06-22 15:12
My work around involved re-introducing “index.php/” to the mix:
In mod.linktracker.php on line 104 change
$apiurl = ‘var actionurl = “‘.$FNS->fetch_site_index().’?uip=’.$ip.’&ACT;=’.$action_id.’&”;’.”\naddEvent(window, ‘load’, addLinkTracker, false);\n”;
to:
$apiurl = ‘var actionurl = “‘.$FNS->fetch_site_index().‘index.php/’.’?uip=’.$ip.’&ACT;=’.$action_id.’&”;’.”\naddEvent(window, ‘load’, addLinkTracker, false);\n”;
2010-06-22 15:01
Hi,
Similar to Shaggy, I’m removing “index.php” from URLs with .htaccess and getting no results with the Linktracker.
If I remove .htaccess, Linktracker works fine.
Is there a work around?
When it works, it’s exactly what I need. Thanks!
2010-04-15 11:19
Hi.
I just tried this on a site we’ve just built - however no links seem to be tracked… I installed on a standard local install and tested and everything works as expected with links tracked in the module control panel…
We have LG .htaccess Generator v1.0.0 installed on the client’s site to remove the index.php so I guess this is the problem… is there an easy fix? or should I look to remove the index.php by another technique?
any pointers would be most welcome! Thanks
2010-04-01 20:49
what about apiurl? Can that be left alone or should it be set to some value? There is also no closing {exp} tag?
[removed][removed]
[removed]
{exp:linktracker:apiurl}
[removed]
2010-01-27 17:28
Hello,
It seems like the link tracker breaks if there is a special character in the URL, anchor text or the Title of the link. Is there any way to resolve this?