WordPress.org

Support

Support » Plugins and Hacks » [Resolved] PiWik and W3 Total Cache and/or CDN

[Resolved] PiWik and W3 Total Cache and/or CDN

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

    @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 http://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.

    danielmichel
    Member

    @danielmichel

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

    Plugin Author braekling
    Participant

    @braekling

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

    danielmichel
    Member

    @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/" : "http://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
    Participant

    @braekling

    Alright, thank you!

    danielmichel
    Member

    @danielmichel

    No problem

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