API: Actions.getOutlinks() - segment for a referring/previous URL


#1

Hi - been at this for days - this is frustrating, can anyone assist me?!

What I want to achieve: call the Piwik API to retrieve a list of outlinks for any given URL.

For example: 'Give me a list of outlink URLs, where the last page the visitor was looking at was ‘http://www.example.com/MyProfile/

What I have tried:

This works:- http://www.example.com/piwik/?module=API&token_auth=xxxx&idSite=12&method=Actions.getOutlinks&format=php&date=last1&period=day

… it gives me an array of OutlinksURLs for the whole site.

But because I only want to know what Outlinks certain pages create, I need to limit the API query in some way. Segments seem to be the option, but none of the URL segment parameters seem to work …

referrerURL
{URL as above}&segment=referrerUrl==http%3A%2F%2Fwww.example.com%2FMyProfile%2F
… produces an empty array: a:1:{s:10:“2012-04-16”;a:0:{}}

pageUrl
{URL as above}&segment=pageUrl==http%3A%2F%2Fwww.example.com%2FMyProfile%2F
… produces an empty array: a:1:{s:10:“2012-04-16”;a:0:{}}

exitPageUrl
{URL as above}&segment=exitPageUrl==http%3A%2F%2Fwww.example.com%2FMyProfile%2F
… produces an empty array: a:1:{s:10:“2012-04-16”;a:0:{}}

What is my problem?!: I have checked using the Piwik dashboard that my page MyProfile did actually have outlinks, and the “Real Time” dashboard confirms this as I click through to MyProfile and then click an outlink. So, Piwik really IS recording the outlink and the page that the visitor was last on before the Outlink. So how come I can;t query this out of the API?

(a) what part of the API am I calling wrongly?
(b) is the Piwik API not able to do this?

(PS - I hope I’ve explained what I’m trying to achieve clearly in order to engage all you API-users’ knowledge!)


(Matthieu Aubry) #2

Thanks for the report. I think it might be a missing feature (there is no segment previousPageUrl==)
because, an outlink becomes the “exit page” so the segment exitPageUrl will not work.

Can you reproduce the same problem on the demo.piwik.org as well?


#3

>> Can you reproduce the same problem on the demo.piwik.org as well?

I began to work with the Demo site, have noted several outlinks that could be tested, but the site’s API call is not producing ANY results for getOutlinks … even if I go back the whole year:-

http://demo.piwik.org?module=API&idSite=3&method=Actions.getOutlinks&format=php&date=last1&period=year

Note that the same test with my site does work - and produces a large array of Outlinks.

So, sorry, cannot begin to proove or disproove that the same problem is in the Piwik Demo site whilst the API is not responding as expected.


(Matthieu Aubry) #4

It works for this other website id: http://demo.piwik.org/?module=API&idSite=7&method=Actions.getOutlinks&format=php&date=today&period=year - thanks


#5

Ok then, back to proving the problem. Looking at Site ID 7, there is the following visitor path:

Tue 17 Apr - 07:17:22
2 Actions - 24s

  1. Welche Ordnerberechtigungen bzw. welche Ordner für ein Update?
    301 Moved Permanently
  2. Piwik Hosting in Deutschland vom Spezialisten - Mysnip Solutions (an outlink)

Now, we can see this outlink event (www.mysnip-solutions.de) in the API:-

http://demo.piwik.org/?module=API&idSite=7&method=Actions.getOutlinks&format=php&date=2012-04-18&period=day

However, if we want to ask the API "show me the outlinks that came from the page 301 Moved Permanently:-

http://demo.piwik.org/?module=API&idSite=7&method=Actions.getOutlinks&format=php&date=2012-04-17&period=day&segment=pageUrl==http%3A%2F%2Fforum.piwik.org%2Fread.php

… we get an empty array.

The same empty array happens when using other URL segments: exitPageUrl, referrerUrl.

So, like you suggest, Matt, there appears to be no segment in the API that defines the page event Piwik recorded visited before the outlink event occurs.

(Background: this requirement came up because a customer wanted certain critical page on his website to show all the outlinks that had occured from the page itself. This information would only be visible to administrators and creators of the pages. The customer didn’t want to have to search through pages of Piwik Dashboard data when (he thought) we could ask Piwik: please show us the outlinks that occured on this URL).

So, what happens now, please?

Best wishes
Dean


(Matthieu Aubry) #6

Dean, thanks for the detailed report. You would need a new segment previousPageUrl= that would match pageviews where the previous page was a given page. Please create a ticket in dev.piwik.org requesting this. AFAIK we will most likely implement it in the next few months.


#7

Ticket raised.