WordPress.org

Ready to get started?Download WordPress

Forums

WP-Piwik
[resolved] PiWik and W3 Total Cache and/or CDN (7 posts)

  1. danielmichel
    Member
    Posted 1 year ago #

    My only problem is that I have PiWik installed on a sub-domain and would like to use W3 Total Cache to either combine it's JS file with the rest of my JS files and/or include it as one of the files I host on my CDN(MaxCDN)
    Thanks in advance for any help

    http://wordpress.org/extend/plugins/wp-piwik/

  2. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. danielmichel
    Member
    Posted 1 year ago #

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

  4. braekling
    Member
    Plugin Author

    Posted 1 year ago #

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

  5. danielmichel
    Member
    Posted 1 year ago #

    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

  6. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    Alright, thank you!

  7. danielmichel
    Member
    Posted 1 year ago #

    No problem

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic