"Fossies" - the Fresh Open Source Software Archive

Member "incubator-pagespeed-mod-1.14.36.1/html/doc/filter-insert-ga.html" (28 Feb 2020, 2724 Bytes) of package /linux/www/apache_httpd_modules/incubator-pagespeed-mod-1.14.36.1.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the incubator-pagespeed-mod-1.14.36.1.tar.gz project site itself.

Insert Google Analytics

Configuration

The 'Insert Google Analytics' filter is enabled by specifying:

Apache:
ModPagespeedEnableFilters insert_ga
ModPagespeedAnalyticsID <Analytics ID>
Nginx:
pagespeed EnableFilters insert_ga;
pagespeed AnalyticsID <Analytics ID>;

in the configuration file. As of 1.10.33.0 the default snippet is now analytics.js. To insert ga.js instead, set:

Apache:
ModPagespeedUseAnalyticsJs false
Nginx:
pagespeed UseAnalyticsJs false;

Description

The 'Insert Google Analytics' filter adds the basic Google Analytics javascript snippet to each HTML page. If the page already has a Google Analytics snippet inside <head> with the specified ID, then no additional snippet will be added. If another Google Analytics snippet is on the page with a different ID, then an additional snippet will be added with the ID specified in with AnalyticsID. In order to avoid any strange Google Analytics reporting, make sure that the ID specified in the configuration file matches the one used on your site.

This filter does not require the make_google_analytics_async filter. The Google Analytics snippets inserted by insert_ga are already asynchronous.

See this example of this filter in action.