Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author braekling

    (@braekling)

    If you talk about the JavaScript loaded by Piwik’s own tracking code, I think it won’t work to put this into a JS collection on your WordPress host. But to get support on Piwik itself please visit https://forums.piwik.org – this forum is just about the WordPress plugin WP-Piwik.

    WP-Piwiks own JavaScript file will only be loaded if a user is logged in and a WP-Piwik chart is shown. Minify or cache plugins should also process these files.

    Thread Starter danny

    (@danielmichel)

    I actually got it to work combining it
    https://d.pr/5rFZ

    Plugin Author braekling

    (@braekling)

    Did it “just work” or is there any hint which may help other users looking for a similar solution? Thanks!

    Thread Starter danny

    (@danielmichel)

    function var_piwik() {
    	if (!is_admin()) {
    		wp_register_script( 'piwik', get_template_directory_uri() . '/js/piwik.js','',null,true);
    		wp_enqueue_script('piwik');
    	}
    }
    add_action('init', 'var_piwik');
    <script type="text/javascript">
    	var _paq = _paq || [];
    	(function(){
    	    var u=(("https:" == document.location.protocol) ? "https://analytics.mysite.com/" : "https://analytics.mysite.com/");
    	    _paq.push(['setSiteId', 1]);
    	    _paq.push(['setTrackerUrl', u+'piwik.php']);
    	    _paq.push(['setVisitorCookieTimeout', '604800']);
    	    _paq.push(['setSessionCookieTimeout', '0']);
    	    _paq.push(['trackPageView']);
    	    _paq.push(['enableLinkTracking']);
    	    var d=document,
    	        g=d.createElement('script'),
    	        s=d.getElementsByTagName('script')[0];
    	        g.type='text/javascript';
    	        g.defer=true;
    	        g.async=true;
    	        s.parentNode.insertBefore(g,s);
    	})();
    	</script>

    then add
    wp-content/js/piwik.js to W3 Total Cache Minify

    Plugin Author braekling

    (@braekling)

    Alright, thank you!

    Thread Starter danny

    (@danielmichel)

    No problem

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PiWik and W3 Total Cache and/or CDN’ is closed to new replies.