How can I get (export) the URLs of the all tracked pages?


#1

Hello. I installed Piwik to my blog. I want to get the URLs of the most tracked blog posts in XML format via Piwik API . I use Actions.getPageUrls method for this. But this method doesn’t give all the URLs. For example, these are the tracked URLs:

http://mysite.com/2011/12/hello-world/
http://mysite.com/contact.php

and it is the XML output of these pages :


<result>
	<row>
		<label>2011</label>
		<nb_visits>15</nb_visits>
		<nb_hits>25</nb_hits>
		<sum_time_spent>30</sum_time_spent>
		<avg_time_on_page>15</avg_time_on_page>
		<bounce_rate>0%</bounce_rate>
		<exit_rate>0%</exit_rate>
		<idsubdatatable>6</idsubdatatable>
	</row>
	<row>
		<label>/contact.php</label>
		<nb_visits>20</nb_visits>
		<nb_uniq_visitors>5</nb_uniq_visitors>
		<nb_hits>6</nb_hits>
		<sum_time_spent>46</sum_time_spent>
		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
		<entry_nb_visits>1</entry_nb_visits>
		<entry_nb_actions>14</entry_nb_actions>
		<entry_sum_visit_length>62</entry_sum_visit_length>
		<entry_bounce_count>0</entry_bounce_count>
		<exit_nb_uniq_visitors>1</exit_nb_uniq_visitors>
		<exit_nb_visits>1</exit_nb_visits>
		<avg_time_on_page>46</avg_time_on_page>
		<bounce_rate>0%</bounce_rate>
		<exit_rate>100%</exit_rate>
		<url>http://mysite.com/contact.php</url>
	</row>
</result>

As you see, there is not url tag in all rows. That’s why, I cant get the URL of blog post.
So, my question is the how can I get (export) the URLs of the all tracked pages?


(Matthieu Aubry) #2

You can add &expanded=1 in the API request.

Then, you have to parse the results and only keep the ones with a attribute.

it is not as simple as it should be, due to the way Piwik “Splits” URL based on the slash / character.