We are trying to make Piwik work for 1 of our applications; if it works out, we will use it for other applications as well.
Here is a scenario that we encountered - we want to find out if we can track the “image clicking” with piwik for this scenario; it is not a simple image posted on a page, so I will break down the steps:
User goes to an url (http://www.mysite.com/Survey/TakeOne/100) to start taking the survey (this url has a idSite 1); note: here “100” is the surveyid; and we plan to add tracking code for idSite 1 on this page;
User clicks “Submit” to go to the last page (http://www.mysite.com/Survey/Result/100) - and here on this page, there will be 3 images – We want to track the clicking of these 3 images here.
Now, our question is:
Must we create a new idSite for this url (http://www.mysite.com/Survey/Result/100), separate from the idSite for the starting page, in order to track the 3 images on the “Result” page?
If yes, that is workable on our end; we just don’t want to miss anything. Our initial thinking was: since it is the same survey, if there is a way to use 1 idSite, that’d be more streamlined, with only 1 idSite; however, we do realize that these pages may be treated as 2 seperate “sites” in Piwik’s term, since they do have 2 different urls.
Thanks for your reply. I have already read through the link you mentioned. I think for our needs (tracking the impression and clicks on images), here is the functions we need to use:
On this page, there are 2 functions that we are thinking about using:
trackContentImpression( contentName, contentPiece, contentTarget ) - Tracks a content impression using the specified values.
trackContentInteraction( contentInteraction, contentName, contentPiece, contentTarget ) - Tracks a content interaction using the specified values.
Now, in the above definitions, there is no idSite mentioned - so it does not seem to be tied into any idSite from just this page; however, the functions on this page are for JavaScript Tracking API; so, my understanding is: we may only be able to use these functions after we set up the “Piwik Javascript Tracker” - which, from this page: JavaScript Tracking Client: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3, it seems that it always have to pass an “idSite” in order for any tracking to work.
Hence my question in the previous post - I would prefer that the tracking of images (impressions and clicks) are NOT tied to any idSite, that would be much more flexible, and be ideal. However, based on the above info that I read, I’m not sure how to implement that in Piwik yet; or does Pwik provide a way to “Track image without idSite”?
Now, how do I retrieve the information programmatically - the # of impressions on each image; the # of clicks on each image? Is there any API calls to make to retrieve that info? I assume so, but have not found the info I need.
Thanks for the reply. Have you used these 2 API calls? If so, can you tell me what they each return? The examples on that page for these 2 APIs are both empty, with no data; so I cannot see what they actually return.
Contents.getContentNames (idSite, period, date, segment = ‘’, idSubtable = ‘’) [ Example in XML, Json, Tsv (Excel) , RSS of the last 10 days ]
Contents.getContentPieces (idSite, period, date, segment = ‘’, idSubtable = ‘’) [ Example in XML, Json, Tsv (Excel) , RSS of the last 10 days ]
If you/anyone can provide that info, with an example, I’d appreciate it very much!
Sure, I have used those API’s and they are used in the UI as well. If you see something in Piwik itself under “Actions => Contents” then those API’s should actually return data.
GetContentPieces returns the same data but it contains a list of all used content pieces instead of names. You might notice that the API returns a “idsubdatatable” property. If you add a URL param to the API-URL eg “&idSubtable=2845” then you will get all content pieces that were used for a given content name.
Make sure you are requesting the data for the correct site id (&idSite) URL parameter. For a test you could also switch the period parameter to “month”. Maybe there is just no data for the current day.
I have tried using the Contents.getContentNames method, in order to get tracking data (nb_impressions, etc.) for the images displayed on our website, but it always returns nothing.
I then logged into piwik, under “Action”, “Contents”, it shows no data - so my understanding is that no data is logged fro these images; thus the API call returns nothing.
BTW - all other api calls to piwik worked so far.
I went to the error log on the web server, and can see that my clicking of the ad images are recorded. Here is from the log:
Plus other clicks on images; recorded in the same order that I have clicked.
So, my question:
If I can see the above log on the web server, that means that the javascript tracker code that I put on my web pages is working, correct?
If yes, why were they not recorded?
The images will be displayed on the very siteUrl that is associated with the idSite, PLUS all subsequent pages. i.e. if it starts with www.mysite.com/page1 (which is the siteUrl on piwik dashboard), then when user submit a form on this page, it will go to Page2, then Page 3, where the url will be different than the original siteUrl.
In this case, if the user clicks on the image from Page1, then Page2, Page3…will these clicks ALL be tracked?
NOte: Our images are hosted in a Amazon S3 bucket, so all of them have a fixed url like this:
It looks good and should mean it’s setup correctly if there was also a content impression looked. The piwik.php call is showing an interaction. An interaction will be only counted if there was an impression before that. Are you seeing requests without the “c_i” parameter but the others like “c_n”?
It should be recorded correctly but see 1). It’s important that an impression is logged as well. Otherwise it’s useless.
They should be all tracked if I remember correctly
However, the content is still not tracked. Meaning: I log into Piwik, go to Actions, go to “Contents” - still no data is there.
You mentioned: " An interaction will be only counted if there was an impression before that. Are you seeing requests without the “c_i” parameter but the others like “c_n”?"
My question is: what do I need to do to ensure that there is an impression before interaction? How do I make sure that an impression is logged ?
After I made the change you suggested, and ran the app., went back to the server access log - I still do not see an "request without the “c_i” parameter ". I see the same log as yesterday; all of them have “c_i=click”.
My question is: what do I need to do to ensure that there is an impression before interaction? How do I make sure that an impression is logged ?
trackAllContentImpressions() should make sure that content impressions are tracked. Otherwise always make sure to call trackContentImpression() with the same parameters when a trackContentInteraction() is called. Maybe it doesn’t detect the content impressions or maybe bulk tracking is not working. Or maybe you don’t see them in the logs as it is a POST request. From the looks it does sound that they are not tracked. I think it would be helpful to add a method to piwik.js that let’s you get information about all content blocks in your page.
Are you familiar with checking network requests in the browsers? You could have a look if a tracking request is sent for this. Will create some issues now!
Update - issue solved. I can see tracking data and retrieve them via api call.
My bad - I did not select the correct website at the top right corner, when checking “Action” -> “Contents” after logging into piwik - the tracking data was there all along.
1 more question: what I’m testing now is for the Dev server; now, for Production server, do I need to set up a new, separate installation for Piwik, create a new DB, correct? Basically repeat the same steps?