Hi,
I have a piwik server setup and the script is added on all pages of the website. The site is deployed on dev, stage and prod and all of them point to the same piwik server. Hence the piwik is displaying the page views from dev, stage and production application.
Is there a way to configure piwik so that, it does not track the page views from dev and stage machine based on the host name or the url of the dev and stage?
Please let me know.
mjut
November 4, 2014, 2:20pm
2
I am looking for this too. Unfortunately, I did not find a solution yet…
matthieu
(Matthieu Aubry)
November 6, 2014, 7:01am
3
maybe the easiest solution is that, in your code, you do not display the piwik tracking code except on production?
if that’s not suitable solution, do you have a suggestion how it should be done?
mjut
November 6, 2014, 10:05am
4
@Matt yes - that would to the thing. Sounds easy. But picture following situation: If i had a live-site (www.site-a.bla) and do not want to track all incoming traffic coming from a second url (www.site-b.bla) is there a way to not track all visitors coming from that page?
matthieu
(Matthieu Aubry)
November 7, 2014, 1:09am
5
is there a way to not track all visitors coming from that page?
yes you can in javascript look for the referrer hostname and skip the PIwik track* functions is the domain should not be tracked
mjut
November 7, 2014, 8:44am
6
Ah thanks! - do I need to alter the piwik tracking code or do i have to write an own javascript?
matthieu
(Matthieu Aubry)
November 11, 2014, 8:13am
7
Here you need to write the code but it should be one line like
if( not referer.contains ('mydomain')) {
// show piwik code
}
(pseudocode)
mjut
November 11, 2014, 12:31pm
8
Great! That seems to be working:
<!-- Piwik -->
<script type="text/javascript">
if( not referer.contains ('mydomain')) {
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//url.com/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
}
</script>
<!-- End Piwik Code -->
Here is another approach. I think, this should work too:
In the outgoing link, I do
<a href="http://www.tracked-website.com/?n=notrack" title="">This link shouldn't be tracked.</a>
On the piwik-tracked website I put:
<!-- Piwik -->
<script type="text/javascript">
if( not referer.contains ('notrack')) {
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//url.com/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
}
</script>
<!-- End Piwik Code -->
This code above is not working. I ended up using this solution:
<!-- Piwik -->
<script type="text/javascript">
if( document.referrer.indexOf("part-of-refer-url.com") > 0){
// document.write("notrack");
} else {
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//url.com/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
}
</script>
<!-- End Piwik Code -->