How to track an individual link?


(Vadi) #1

Hi,

How can I tag and track an individual link?


(vipsoft) #2

By default, Piwik should already be tracking your links (except those being explicitly ignored).

If you’ve added a link (e.g., via DOM manipulation), then no, Piwik won’t track it because Piwik doesn’t know about it. And at the moment, there’s no built-in method within piwik.js to add a listener to track that link if/when clicked. (This should be rectified in ticket #355.)

For your reference: http://piwik.org/docs/javascript-tracking/


(Vadi) #3

Sorry, it does track them fine - but if lets say I have two links pointing to the same location, and I’d like to differentiate them in stats, what can I do?


(vipsoft) #4

Add something innocuous to the URL, e.g.,


#5

It’s 2 years later.

How do you track an individual link? At the moment I am forcing individual links to get tracked as Outlinks, but this isn’t a real solution.

Am I missing something?


#6

you could try creating goals for the links and triggering them manually, dunno if that’s what you need


#7

The links in the image carousel on the home page are a combination of internal and external links. One could also reach these pages from several other areas of the site, e.g. menu etc. However, it is very important for me to know exactly how many times a user clicked on the link in the image carousel on the home page.

The only solution I know of is to 1) force the internal links to get tracked as outlinks, and 2) force the outlinks to get tracked as downloads, and 3) then setup goals for those forced outlinks and downloads. However this seems like a ridiculous workaround. Is there no other way?

I wish I could give the link a class such as “piwik_click_tracker” and then set up a goal with the trigger “Hit on a click tracker” That seems more logical to me.


#8

[quote=Keeling]
The links in the image carousel on the home page are a combination of internal and external links. One could also reach these pages from several other areas of the site, e.g. menu etc. However, it is very important for me to know exactly how many times a user clicked on the link in the image carousel on the home page.

The only solution I know of is to 1) force the internal links to get tracked as outlinks, and 2) force the outlinks to get tracked as downloads, and 3) then setup goals for those forced outlinks and downloads. However this seems like a ridiculous workaround. Is there no other way?

I wish I could give the link a class such as “piwik_click_tracker” and then set up a goal with the trigger “Hit on a click tracker” That seems more logical to me.[/quote]

that’s what i meant, you CAN create goals for a certain action, and then trigger the goal from javascript ( if you’re using the jQuery javascript framework you can bind an action to the click and call the trigger there, something like $(’.piwik_click_tracker’).bind(‘click’,function(){ tracker.trackGoal(goal_id); }); )


#9

Thanks for you help, but this sounds like a complicated developer solution rather than a simple plugin solution. I think a plugin solution for this problem would be a reasonable feature request.

Could you please point out where I can find information in the PIWIK documentation about “create goals for a certain action, and then trigger the goal from javascript”? Thanks again.


#10

Track Goals and Measure Conversions - Analytics Platform - Matomo this is where i started

if you’re going to use javascript to trigger the goals, you will have to set them to trigger manually
other than that, the documentation there should provide everything you need


#11

I eventually figured this out, however I didn’t find the answer anywhere in the documentation.

If you would like to track an individual link try the following:

  1. Create a new Goal and be sure to set “Goal is triggered” to “Manually”
  2. Click “View and Edit Goals” and note the ID for the goal you just created
  3. Add the following Javascript to the link that you would like to track and be sure to replace “ID” with the goals actual ID number: onclick=“piwikTracker.trackGoal(ID);”

For example:
New Product
New Product

I hope that this helps someone.


(Sorin Postelnicu) #12

@Keeling, This is exactly the same what razvan_dev suggested with the jquery onclick. :slight_smile:
Maybe the javascript syntax for calling jquery intimidated you for a second :slight_smile:

But the advantage of the jquery solution is that you don’t have to mess with your html to add ugly “onclick” to links, but instead you can do it cleanly in a separate js file.

Html content should not be intermixed with javascript events, but the binding of events should be done dynamically and preferably in a separate javascript file.