Google's Universal Analytics is out of beta, so now is a good time to update any Google Chrome extensions with the new code. Except that Google haven't updated their tutorial just yet.

Here's the steps for adding Universal Analytics to your Google Chrome extension:

Update your manifest.json


"content_security_policy": "script-src 'self'; object-src 'self'"


Update your Options page

I'm just assuming here that you want to track events in your options page. In your options page e.g. at /options.html, add a reference to the tracking javascript in a separate file:

<!DOCTYPE html>
<script src="js/options.js"></script>

Update your tracking code

Add the tracking JavaScript e.g. at js/options.js with the Universal Analytics code. Note the "https" at the start of the script address.

// Standard Google Universal Analytics code
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
})(window,document,'script','','ga'); // Note: https protocol here

ga('create', 'UA-XXXXX-YY', 'auto');
ga('set', 'checkProtocolTask', function(){}); // Removes failing protocol check. @see:
ga('require', 'displayfeatures');
ga('send', 'pageview', '/options.html');

There are 3 points I'd particularly like to highlight:

  1. Specify "https" at the start of the script address to match with the listing in the manifest.json file
  2. Override checkProtocolTask with an empty function
  3. Send a virtual pageview by specifying the path – '/options.html' – otherwise Google Analytics will reject a URL in the format

If that all went well, you should soon see page tracking in Google Analytics, like so: