I am trying to programmatically obtain the javascript tracking code. I am able to obtain what I thought was the tracking code using getJavascriptTag, and insert it into my sites, but I don’t see any visits in the piwik dashboard. What I did notice was that the tracking code I am using has a pkBaseURL value equal to the URL from where the getJavascriptTag method was called in my original php script (the one that obtained and stored the tracking code), NOT the location of piwiki. To reproduce:
If I call SitesManager.getJavascriptTag from within piwik (example.com/piwik), it returns this:
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.example.com/piwik/" : "http://www.example.com/piwik/");
...
<!-- End Piwik Tracking Code -->
When I call the same function, but within php code from another page, say from example.com/myfunction, i get this:
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.example.com/myfunction/" : "http://www.example.com/myfunction/");
...
<!-- End Piwik Tracking Code -->
According to piwik, I should paste the code it has given (the one with example.com/piwik) “in all the pages you want to track with Piwik”, so basically I’ve been inserting the wrong code… How can I get the code that piwik wants me to put in all pages using the API, if getJavascriptTag won’t do it?