Puddinq.com sharing knowledge

Analytics in wordpress (cached)

Analytics in wordpress (cached)

Google-Analytics Verion: 0.1.0

Though www.google.nl itself does not get an impressive score when run through PageSpeed Insight. You might frown when you added the analytic script as Google instructed and Google tells you it is not right when you check your site on PageSpeed. For wordpress I made a plugin that solves this: It downloads the analytics.js, puts it in /content/uploads/ and inserts the tracking script calling analytics.js from the server (and not goole).

You only have to install the plugin and add your tracking code. The plugin will download the script daily (wp cron) to make sure it is a recent copy.

The original error displayed:

Leverage browser caching Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network. Leverage browser caching for the following cacheable resources:http://www.google-analytics.com/analytics.js (2 hours)

Plugin settings and added code:
nf g analytics settings

nf g analytics code


Download NF Google Analytics embed



You can just upload the files in your plugin folder or upload the zip using the admin page.

the plugin assumes domain/content/uploads/ exists.

Download NF Google Analytics embed