webfactory / piwik-bundle

Symfony Bundle with twig-function for the Matomo (fka Piwik) tracking code
MIT License
39 stars 16 forks source link

Add <noscript> to piwik_code() #11

Closed nwoetzel closed 5 years ago

nwoetzel commented 8 years ago

Piwik FAQ: How do I enable tracking for visitors that have disabled Javascript?

When the visitor disables javascript, there would be no tracking. Piwik suggest to add

<noscript><p><img src="http://piwik-server.com/piwik.php?idsite=1&rec=1" style="border:0" alt="" /></p></noscript>

which does not have the full tracking functionality, but is a good backup plan. Could I submit a pull request to include this? Would you prefer to have an argument to the piwik_code function call

{{ piwik_code(noscript=true) }}

Or should it be a configuration parameter? Or anything else?

mpdude commented 8 years ago

I think it would be great to have this included so our users don't need to remember this :)

Looking at the FAQ page you linked, there seem to be some parameters (rec and bots in particular) that would be nice to have as configuration values with sensible defaults.

Do you understand the importance of having rec set?

nwoetzel commented 8 years ago

Thanks for the quick reply. http://developer.piwik.org/2.x/api-reference/tracking-api So it seems that without rec=0 there would be no tracking. I guess that it is there, so that if you no want to disable tracking (like in development mode) it would still generate the url, the browser loads it - but the piwik-server would ignore it. So you can easily disable tracking without removing the code... In theory, I would go as far as to allow setting all HTTP API query parameters is wanted. And in the configuration, as you said, define sensible defaults (e.g. site_id, rec, api_v). One could even take care of the rand=1285698456-0123456 that is suggested to include to prevent caching of requests. (I think the javascript tracking code does that by default) Now that I think about it, having a second function {{ piwik_code_api() }} that just generates the <img src="http://piwik-server.com/piwik.php?idsite=1&rec=1" style="border:0" alt="" /> portion would be cleanest. And using {{ piwik_code(noscript=true) }} would be very close to

{{ piwik_code() }}
<noscrip><p>{{ piwik_code_api() }}</p></noscript>

where noscript=true would pretty much just be a helper for the above. And this could be set in the configuration as default, so that no layout has to be changed.

relthyg commented 5 years ago

We've added the <noscript> element in v2.5.1. Does this solve thise issue?

TomaszGasior commented 5 years ago

It seems to be this bug can be closed sine last commits which solve this issue.

mpdude commented 5 years ago

Thanks!