BoxLang 🚀 A New JVM Dynamic Language Learn More...

PresideCMS Extension: Google Analytics

v1.0.3+0000003 Preside Extensions

Google Analytics for Preside

This extension allows you to easily insert Google Analytics "tags" into your Preside website's pages.


From a commandline at the root of your application:

box install preside-ext-google-analytics


Once installed, login to the Preside admin and head to System -> Settings -> Google Analytics and enter your analytics credentials.


The extension will take care of inserting analytics "tags" into your layout automatically for you, you won't need to do anything else. However, you can customize the layouts that are effected and the script itself.

To customize the layouts, set the settings.googleAnalytics.layouts variable in your Config.cfc:

settings.googleAnalytics.layouts = [ "main", "newsletter" ]; // default is [ "main" ]

To customize the output of the analytics script, implement your own view at /views/general/_googleAnalyticsTags.cfm, the view will be passed two args: gaId and layout. For example:

// /views/general/_googleAnalyticsTags.cfm
<cfparam name="args.gaId"   type="string" />
<cfparam name="args.layout" type="string" />

<cfif args.layout == "main">
	<cfoutput><invalidTag type="text/javascript">(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ga('create', '#args.gaId#', 'auto');
ga('send', 'pageview');</script></cfoutput>

<cfelseif args.layout == "newlsetter">
<cfoutput><invalidTag type="text/javascript">some special example for newlsetters here</script></cfoutput>

Contributing and roadmap

Pull requests, issues and ideas are all welcome :) Please use Github or get in touch with the Preside team on our Preside Slack.

We could obviously do a lot more with this extension and would be great to collaborate with anyone who has ideas!



  • Move build process to GitHub Actions
  • Delayed viewlets support for body tag


  • Add option to anonymize IPs


  • Initial release

$ box install preside-ext-google-analytics

No collaborators yet.
  • {{ getFullDate("2018-04-19T06:49:26Z") }}
  • {{ getFullDate("2021-01-18T10:59:57Z") }}
  • 1,978
  • 28,998