Error when Adblock enabled

Hi. I’m using piwik in combination with the wordpress plugin. I’ve already informed the author of the plugin but I think you might be interested in too.

The following case is required that an javascript error occures:
The user has Firefox with Adblock and Dr. Evil’s Filter List ( enabled. This list is widely used by German speaking users.

The list blocks “/piwik.js”. But does not prevent the execution of the javascript tag part of piwik.

So when piwik.js was not loaded the tag part throws an error because of undefined vars/functions and so prevents the further execution of any javascript that might would have been executed on the rest of the page.

I temporarily fixed this in the following way (fix is for the plugin, not for piwik itself):

<!-- Piwik code inserted by Piwik Analytics Wordpress plugin by Jules Stuifbergen http://blog.jongbelegen/piwik -->
                <script language="javascript" src="<?php echo $options["jsurl"]; ?>" type="text/javascript"></script>
                <script type="text/javascript">
                if (typeof _pk_install_tracker == "undefined") {
                    $('footer').appendChild(new Element('img', {
                        'src': '<?php echo $options["phpurl"] . "?idsite=" . $options["siteid"]; ?>',
                        style: 'border:0',
                        alt: 'piwik'
                    piwik_action_name = document.title;
                <?php if ( ! $options["dltracking"]) { ?>
                    piwik_install_tracker = 0;
                <?php } elseif ($options["dlextensions"] != '7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip' ) { ?>
                    piwik_download_extensions = '<?php echo $options["dlextensions"]; ?>';
                <?php } ?>
                    piwik_idsite = <?php echo $options["siteid"]; ?>;
                    piwik_url = '<?php echo $options["phpurl"]; ?>';
                    piwik_log(piwik_action_name, piwik_idsite, piwik_url);
                <noscript><p>Web analytics <img src="<?php echo $options["phpurl"] . "?idsite=" . $options["siteid"]; ?>" style="border:0" alt="piwik"/></p>
                <!-- /Piwik -->

The important part is:

if (typeof _pk_install_tracker == "undefined")
 (add the static image for tracking)
 (print default piwik code)



Rename piwik.js to something less detectable. Then change these files were the filename is hardcoded:

  • core/Tracker/javascriptTag.tpl
  • misc/testJavascriptTracker/page2.php
  • misc/testJavascriptTracker/index.php
  • plugins/CoreHome/templates/piwik_tag.tpl

Thanks for the quick reply.

I suggest to add the possibility to set the js file name somewhere in config space. Because in this case I have to patch it after updating. And I tend to keep my apps up2date style_emoticons/<#EMO_DIR#>/smile.gif

We’ll need more votes in favor of this one. (This feature request was previously marked wontfix.)

a confile filename flag makes sense - or block firefox users style_emoticons/<#EMO_DIR#>/wink.gif g

or is it possible to markthem seperatly?

Another idea is to use mod_rewrite.

Doesn’t work because Adblock Plus picks up on this through the content policy filter.

I added your suggestion as a requirement for the new javascript tracking code.

A simple way to do this would be to surround the code by a try { } catch block.