Piwik+Notes

back to main page
I installed a copy of piwik on my local desktop server for the purposes of testing. Installation is trivial.

Started testing out some API calls based on http://dev.piwik.org/trac/wiki/API/Reference to confirm what we hoped could be done can in fact be done

SitesManager.addSite (siteName, urls, excludedIps = , excludedQueryParameters = , timezone = , currency = ) [ No example available ]


 * N.B.** edited piwik/plugins/SitesManager/api.php, commented out "isAdmin" query so that below would work

e.g. - http://127.0.0.1:8888/piwik/?module=API&method=SitesManager.addSite&siteName=api%20test&urls[0]=http://www.edtechpost.ca&token_auth=1bd888859c7c70f14075c855ef2f03d8

Results in a site with id=2. Use this to send follow up call

http://127.0.0.1:8888/piwik/?module=API&method=SitesManager.getJavascriptTag&idSite=2&format=Html&token_auth=anonymous

which returns the javascript tracking code to generate (N.B. initial call ran with user=solr_guest, but that account did NOT seem to get permissions automatically)

 var pkBaseURL = (("https:" == document.location.protocol) ? "https://127.0.0.1:8888/piwik/" : "http://127.0.0.1:8888/piwik/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));  try { var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 2); piwikTracker.trackPageView; piwikTracker.enableLinkTracking; } catch( err ) {} 

=Concerns/Questions=
 * what account to run these under?
 * Is there a way to generate all of the trackers and then have a guest account that can view them all automatically?
 * It seems as though the siteID is simply generated sequentially; you can pass it the site URL and name when you generate it with SiteManager.addSites but how to then connect the reports programattically with the SOL*R records/resources?
 * if we use the SOL*R resource URL as the site URL, then we can use http://127.0.0.1:8888/piwik/?module=API&method=SitesManager.getSitesIdFromSiteUrl&url=http://solr.bccampus.ca:8001/bcc/item.jsp?uuid=xxxxxxxxxxxx as the way to find the related siteID//