Skip to main content

filter · HTML filters

Insert Google Analytics (insert_ga)

Category:
HTML
CoreFilters:
No
OptimizeForBandwidth:
No
Risk:
Deprecated

Inserts the Google Analytics snippet for the account in AnalyticsID into every page. Deprecated: the snippet it inserts is the retired ga.js, and AnalyticsID itself only targets Universal Analytics, which was discontinued. Add your analytics in your templates instead.

When to use it

  • Not in CoreFilters: it runs only when you enable it by name.
  • Risk rating on these docs: Deprecated.
  • Inserts the retired ga.js Google Analytics snippet.

Risks

The HTML filters page lists no specific risks for this filter. If a page misbehaves with it, DisableFilters insert_ga turns it off for the scope you set it in.

Configuration

Enable it in the module configuration, at server, virtual-host or location scope:

Apache

ModPagespeedEnableFilters insert_ga

nginx

pagespeed EnableFilters insert_ga;

IIS (pagespeed.config)

pagespeed EnableFilters insert_ga

Scoping, ForbidFilters and the thresholds filters read: Choosing filters .

Frequently asked questions

What does the insert_ga filter do?
Inserts the Google Analytics snippet for the account in AnalyticsID into every page. Deprecated: the snippet it inserts is the retired ga.js, and AnalyticsID itself only targets Universal Analytics, which was discontinued. Add your analytics in your templates instead.
Is insert_ga enabled by default?
No. insert_ga is not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name with EnableFilters.
How do I enable insert_ga on Apache and nginx?
Add ModPagespeedEnableFilters insert_ga on Apache or pagespeed EnableFilters insert_ga; on nginx. On IIS, add pagespeed EnableFilters insert_ga to pagespeed.config.

This page is drawn from the insert_ga entry on HTML filters. Every filter in one table: PageSpeed filters.

Google Analytics, AdSense, Fonts and Hosted Libraries are Google products. We-Amp isn't affiliated with or endorsed by Google.

Search