Tracking using Piwik rest api

Hello,

I am trying to track the usage of my REST API by using the Piwik’s REST API. I am requesting to the below URL from my API,

mywebsite.com -&nbspThis website is for sale! -&nbspmywebsite Resources and Information.<my_auth>&rec=1&url=<my_url>

I have only one website configured which has “siteId” 1. When I request to the above URL, it says “Invalid idSite”. I am not sure why this fails because the “idSite” is indeed correct.

Any help to fix this issue would be great.

can you use piwik 2.0 from Index of /

and try again ?
also check your token_auth has “admin” access to the idsite.

Thanks for responding.

I have upgraded to Piwik 2.0-a14. But still it is not working. When I request to the above URL, it gives me a 1x1 image back. It is not tracking anything. What am I doing wrong?

Any help would be great.

Are you using DoNotTrack ? try a different browser?

I am trying with the following curl command.


~ %   curl -d token_auth=<token_auth> -d rec=1 -d url=learn -d action_name=Test -d idSite=1 http://mywebsite.com/piwik/piwik.php

This command outputs something like the following.


GIF89a?!?,D;

When looked at the dashboard, I don’t see the tracking. I am assuming if all works well, it should come up in “Visists over time” widget, right?

Thanks

You can debug with: http://piwik.org/docs/tracking-api/reference/#toc-debugging-the-tracking-api-requests

Thanks. This is the output with debug enabled.


Debug enabled - Input parameters: <br/>array ( 'idSite' => '1', 'token_auth' => '<token_auth>', 'rec' => '1', 'url' => 'learn', 'action_name' => 'learn', )
Error:General_ExceptionConfigurationFileNotFound

array (
  'piwik_auth' => 'login=czoxMToibmF2YW5lZXRoa24iOw==:token_auth=czozMjoiZDM2YjQ0ZDQ2MDA4OWQzZTU4OTA0NDI4MjRiMGUxODciOw==:_=1e3112bd22f1f8ec9d92cd2c37748bcd0b55b8e4',
  'PIWIK_SESSID' => 'uijgc96nlufreg62jbpp36ls57',
)

Piwik\Timer::__set_state(array(
   'timerStart' => 1381899362.1272,
   'memoryStart' => 3340984,
))

There was some problem with my previous installation. Config.ini.php was missing. So I reinstalled Piwik 2.0-a14. Now Config.ini.php is created. But when I request to the URL, I still get invalidIdSite. Again the idSite that I am passing is correct. Here is the full output.


Debug enabled - Input parameters: <br/>array ( 'idSite' => '1', 'token_auth' => '<auth>', 'rec' => '1', 'url' => 'learn', 'action_name' => 'learn', )
Loading plugins: { Provider,Goals,DoNotTrack,UserCountry }
Current datetime: 2013-10-16 05:23:04
Piwik # Web Analytics

Invalid idSite
Backtrace:

#0 /var/lib/openshift/5254daffe0b8cd3b66000097/app-root/runtime/repo/php/piwik/core/Tracker/VisitExcluded.php(38): Piwik\Tracker\Request->getIdSite()
#1 /var/lib/openshift/5254daffe0b8cd3b66000097/app-root/runtime/repo/php/piwik/core/Tracker/Visit.php(91): Piwik\Tracker\VisitExcluded->__construct(Object(Piwik\Tracker\Request), 'u???')
#2 /var/lib/openshift/5254daffe0b8cd3b66000097/app-root/runtime/repo/php/piwik/core/Tracker.php(263): Piwik\Tracker\Visit->handle()
#3 /var/lib/openshift/5254daffe0b8cd3b66000097/app-root/runtime/repo/php/piwik/piwik.php(92): Piwik\Tracker->main()
#4 {main}

Any help to debug this issue would be great!

can you please delete all files and the database and install a fresh 2.0-b1 ? it should work but if not let me know ill investigate!

http://forum.piwik.org/read.php?2,106854

Hello,

Thanks again. I installed 2.0-b1. The problem still persist. Any clues to debug? I can share the screen and show you the issue if required.

what is the full error message you get on 2.0 beta ?

Exception is the same.


Debug enabled - Input parameters: <br/>array ( 'idSite' => '1', 'token_auth' => '<auth>', 'rec' => '1', 'url' => 'learn', )
Loading plugins: { Provider,Goals,DoNotTrack,UserCountry }
Current datetime: 2013-10-16 07:06:21
Piwik # Web Analytics

Invalid idSite
Backtrace:

#0 /var/lib/openshift/5254daffe0b8cd3b66000097/app-root/runtime/repo/php/piwik/core/Tracker/VisitExcluded.php(38): Piwik\Tracker\Request->getIdSite()
#1 /var/lib/openshift/5254daffe0b8cd3b66000097/app-root/runtime/repo/php/piwik/core/Tracker/Visit.php(91): Piwik\Tracker\VisitExcluded->__construct(Object(Piwik\Tracker\Request), 'u???')
#2 /var/lib/openshift/5254daffe0b8cd3b66000097/app-root/runtime/repo/php/piwik/core/Tracker.php(263): Piwik\Tracker\Visit->handle()
#3 /var/lib/openshift/5254daffe0b8cd3b66000097/app-root/runtime/repo/php/piwik/piwik.php(92): Piwik\Tracker->main()
#4 {main}

use &idsite= intead of &idSite=

That fixed it. Works well. Looks like documentation says to use “idSite” which was causing the trouble.

However I noticed another issue (should I open a new issue?). For some reason, my visists are recorded as “United States”. But I am requesting from India. IP lookup says the country is India. But Piwik, takes it as US. How is this happening?

Any help would be great

I agree it’s quite confusing because Analytics API uses idSite.

Have you seen idSite in any tracking API documentation?