I have 2 sites: one HTML-site and one php-site.
On the HTML-site PIWIK is working fine sinds a few years now :).
Recently I updated PIWIK (1.8.3) and added a new site (php).
The HTML-site is still working fine, but the php-site does not track anything.
The PIWIK tracking code I use is for both sites the same, except for the ID-numbers.
I had the same problem also with Google Analytics.
I solved the problem with the Google Analytics tracking code by replacing alle the ’ with ". X(
For the PIWIK tracking code replacement of ’ by " did not work?!?
My PIWIK script is located in the HTML-site.
And recently I added in my PIWIK control panel a new site (that has a php index), but this new site shows no tracking.
The URL of this site which is not working is:
www.starterscom.nl.
As I mentioned before I did not succeed to paste the tracking code before the and make the PIWIK script work. While this was no problem in my other site.
When I paste the tracking code, my homepage of starterscom.nl can not open (template error). I think this is due to the ’ in the tracking code (I think the ’ are cutting of the echo statements).
Replacement of the ’ with " does not work for the PIWIK tracking code.
While the same problem in the Google analytics tracking code was solved by replacing the ’ with ".
the {single quote} in the tracking code is just my whole problem.
When I use the original javascript tracking code in my php-index page with the {single quote} then my site can’t open (template error). In my other site (HTML-index) I use the original tracking code with {single quots} without problems.
This is why I replaced all the {single quotes} with {double quotes} in the new site starterscom.nl. Now my site opens but the PIWIK script does’t track anything.
my php-index page looks like this:
echo’
It’s like the {single quotes} in the tracking code are cutting of the echo statement and then give the template error.
If you have a php statement which is enclosed by single quotes and want to have another single quote within the string you need to escape the character with a backlash, e.g.
$foo = 'That\'s nice';
would echo out as That’s nice. If you’d just have the single quote without the backslash PHP would think the string is finished and give syntax error for the rest.