Using the piwik tracking snippet in svg based sites


Hi all,
I have been using piwik for quite a while now, it serves my simply requirements fine.

Some time ago I implemented and documented a strategy to automatically add the tracking snippet to all sites delivered by a given http server. That strategy has served me well, it saves quite a lot of time especially when often changing the layout of your site universe. Here is the public documentation of that strategy:

Today I tried to apply that strategy to an additional site and filed. This is why and where I would like to ask your help:
The additional site is not html based, it is a pure svg based site. So the main (index) document is of type svg. Obviously I had to adapt the strategy above for this, since an svg document does not have a body tag. No problem, I implemented two separate substitution rules. That was all that was required, since the strategy already considered the mime type of delivered documents to decide when to add the tracking snippet. I succeeded in adding the piwik tracking snippet to the given svg document. The snippets script is also executed, I can step through it in my browsers development console, nor error is shown, variable values look fine to me. But it fails to perform the tracking request which obviously is the ultimate goal. I do not really understand how the snippet works, so that is where I need your help:
Why does that snippet not work inside an svg document, although the snippet is executed? Or asked the other way 'round: what as to be modified to make the snippet work as expected inside an svg document?


I found the solution by asking for help on the StackOverflow site:

(Matthieu Aubry) #3

Hi there,

that’s quite interesting. I’m moving this topic to the Knowledge base forum as it may help others!



Sure, fine with me! I took the opportunity to write another short blog post about the topic. Feel free to add the link as well:

Using the piwik tracking script snippet inside SVG based documents