How to Track Users Without Third-Party JavaScript
I love CSS-Tricks, but recently Jeremy Keith wrote an article about third-party scripts that left me scratching my head. Jeremy made his point about third-party JavaScript on websites very clear. “Don’t add any third-party scripts to your site.” and “…the one thing people can do to make their website better is to not add third-party scripts”.
Fair enough. Third-party scripts can be bad, and I was not very impressed when Font Awesome went from using CSS files to JavaScript files to load their fonts.
But Jeremy knows there are other ways to track users without JavaScript, right? First off, Google does it all the time with their <noscript>
embed code that comes with any Google Analytics installation.
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
Outside of JavaScript and iframes though, you can still track users with server-side scripting. For example, you can call a fake image like this:
<img src="fake-image.php"><!--or like this...--><style>
body:after { background-image: url(fake-image.php) }
</style>