The Missing Stat: noscript

I use Google Analytics for my web sites, you might use Mint or something else bespoke, but if you’re using JavaScript to track those stats (as Google does), you’re not capturing how many users you have that don’t have JavaScript installed.

I’ve written a plugin which I’ll share with you and also explain how it works (so you can add it to a non-WordPress site).

WordPress Plugin

The WordPress plugin has it’s own control panel that you’ll need to add your site’s analytic’s ID, something like UA-12345-6, save settings and you’re off.

Download the noscript wordpress plugin


All the stats on users without JavaScript will be stored under a page /noscript, the page the user was actually on will be the page referring to /noscript.

noscript reporting

Doing it manually

Doing it manually is very simple. If you want to record where the user is coming from, then you’ll want to grab this code, and replace the variables with your own values. I’d recommend either grabbing the plugin and whipping the code out of there, or copying the code below and making the changes for your own site.

$var_utmac = 'UA-12345-6'; // your identifier
$var_utmhn = ''; //enter your domain
$var_referer = @$_SERVER['HTTP_REFERER']; //referer url

$var_utmp = '/noscript'; //this example adds a fake file request to the (fake) tracker directory

$var_utmn = rand(1000000000,9999999999); //random request number
$var_cookie = rand(10000000,99999999); //random cookie number
$var_random = rand(1000000000,2147483647); //number under 2147483647
$var_today = time(); //today
$var_uservar = '-'; //enter your own user defined variable

$urchinUrl = ''.$var_utmn.'&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn='.$var_utmhn.'&utmr='.$var_referer.'&utmp='.$var_utmp.'&utmac='.$var_utmac.'&utmcc=__utma%3D'.$var_cookie.'.'.$var_random.'.'.$var_today.'.'.$var_today.'.'.$var_today.'.2%3B%2B__utmb%3D'.$var_cookie.'%3B%2B__utmc%3D'.$var_cookie.'%3B%2B__utmz%3D'.$var_cookie.'.'.$var_today.'.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D'.$var_cookie.'.'.$var_uservar.'%3B';

echo '<noscript><img src="' . $urchinUrl . '" /></noscript>';


Then later, let’s share the results and see what kind of sites actually have visitors with JavaScript disabled. That kind of information makes me more comfortable with things like the HTML5 shiv.

21 Responses to “The Missing Stat: noscript”

  1. In the example on this page, change:

    echo '<noscript>' . $urchinUrl . '</noscript>';


    echo '<noscript><img src="' . $urchinUrl . '" /></noscript>';
  2. Nice work Remy, I’ll give this a shot tonight.

  3. Remy, This is great! I’ve been annoyed forever about not getting non-javascript users stats. This is huge.

    One question though: Will it still filter search engine bots and spiders out of the traffic? I wouldn’t want those stats in the results, as it wouldn’t be a clear picture of the actual users going to the site.



  4. @Luke – yep, Google shouldn’t cause it to skew stats because the noscript logging is inside an image, which Google won’t/shouldn’t pull.

    That said…they index images…hmm, interesting. rel="nofollow" isn’t valid on images (I think) so it might be worth checking out referrer logs to see. I’ll take a look and report back here later.

  5. Would it make more sense to use events rather than fake pages? Or will that just make it difficult to do comparisons? I’ve switched to using events for external links and downloads… means you don’t dirty up your data with fake stuff.

  6. @Jeff – I’ve not played with events (I assume this is something in Google analytics), so yeah, I’d say it might make sense to track it there. For me, I had no idea on the number of people, so the first port of call was to catch these users to work out what the numbers are.

  7. Hey Remy, this is great! do you mind if I port it to .NET?

  8. @Erik – absolutely go ahead! Cheers.

  9. Hey Remy, ported it to .NET, it’s up at . still waiting for the tracked result to get to my GA Account to verify that it works :)

    Will write a post about it once I’m sure it’s working correctly…

    Cheers and thanks for the awesome sample,


  10. Wow Great article and Thanks a ton.
    Definitely going to be incorporating this plugin into my current plugin mix

  11. Is it possible to use this as the main form of tracking? I hate having to load this JavaScript and slowing down my site.

  12. Hey Remy,
    Finished the port to .NET, works like a charm, thanks again for the great idea and code.

    Have a look :



  13. Remy – I’ve ported it to ColdFusion and posted the snippet and link back at

    Your post is very timely – I need an answer to this question so we’ll be rolling this out to our site ASAP to capture the data. Thanks!

  14. Hey,

    I’ve started a GA.CFC which is available at GitHub here: if anyone reading this is interested in developing this further.

    I also wrote a bit about my plans for the future of GA.CFC here:

    Which, briefly, is to port the Visitor tracking, Page tracking, Event tracking (those events capable of being recognized by the server that is), and more GA features to GA.CFC from GA.JS

  15. You’re going to see lots of bot hits…

  16. ok….here goes. First this allows to track mobile devices that doesn’t have javascript enabled and so on. Ok….bots….emmmm. Very good question. I think you’ll get loads of them so you’ll be thinking they’re your visitors. This is why javascript is enabled for google analytics.

    My question, as you type in your url… takes your ip address….then…..won’t all your users be based in the same city as you. Ok….putting url in image should sort this.

    Now… is this php code? i just add

    < ?php ?>

    around the code, add the analytics number and take out the original code on every page?

  17. It looks like a great idea Remy, have implemented on my homepage above, let’s see how many of the handfull of folks who look look at it have no JavaScript support. This may take a while. Looking forward to comparing my results to the ones that will appear above soon though.

  18. I have wordpress and Non-wordpress sites. I would love it if you could explain how this works so I could apply it to any GA site. Perhaps refer me to an article? Please.


  19. Since this is only triggered by noscript, I assume we can just run this in parallel with the standard GA JS code block. Any methods up your sleeve for standard HTML pages? The other option would be to run awstats or something and look at those logs for calls to the fake noscript image.

  20. Hi Remy,

    thanks for sharing your solution to this issue!

    I’d replace all ‘ & ‘ in the URL by ‘ & ‘ and add a ‘ alt=”" ‘ to the image tag though in order to avoid XHTML validation errors… ;)


  21. What is the user defined variable supposed to do? I’ve changed it but see no noticeable effect.

    Thanks for sharing the script.

Leave a Reply
Not required

CODE: Please escape code and wrap in <pre><code>, doing so will automatically syntax highlight