• Hey everyone

    I am looking to track how many visitors to my site have a retina display and I have the code (below) but I am having some troule adding this to Google Analytics for WordPress.

    Does anyone know how to tweak the header info in this plugin or would it be easier for me to stop using it and just add the code manually?

    var pixelRatio = (window.devicePixelRatio >= 1.5) ? "retina" : "normal";
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
    _gaq.push(['_setCustomVar', 1, 'Pixel Ratio', pixelRatio, 2 ]);
    _gaq.push(['_trackPageview']);
    (function() {
          var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
          ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
          var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

    All I need to add is
    var pixelRatio = (window.devicePixelRatio >= 1.5) ? "retina" : "normal";
    and
    _gaq.push(['_setCustomVar', 1, 'Pixel Ratio', pixelRatio, 2 ]);
    Any help would be awesome!

    Thanks

    Dan

    http://wordpress.org/plugins/google-analytics-for-wordpress/

  • The topic ‘Custom Variables for Retina Displays’ is closed to new replies.