Analytics
Last updated Mar 12th, 2021 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$301 per month—let's make that $500!
Learn moreWhat is Analytics?¶
Analytics is a utility tool for MODX Revolution that will insert the tracking code for Google Universal Analytics (analytics.js) and/or Google Analytics (ga.js) on your website's pages.
By default it will ignore traffic from users logged into the manager. Every context in your website can be excluded on demand, wether or not users are logged in. The tracking code templates can be overridden with your own chunk.
Requirements¶
- MODX Revolution 2.1.5 or later
- PHP5 or later
History¶
Analytics was first released on February 5th, 2012 by yogoo. The idea of making this extra emerged after reading Mark Hamstra's blog post: Hiding code for MODX Manager users.
Download¶
The extra can be retrieved through the Package Manager, or downloaded manually from the repository.
Usage¶
Usage examples¶
Most basic call (always uncached):
[[!Analytics? &webPropertyID=`UA-XXXXX-Y`]]
Disable context filtering (cache the snippet):
[[Analytics?
&excludeContextList=``
&excludeLoggedInUserContextList=``
&webPropertyID=`UA-XXXXX-Y`
]]
Advanced example:
[[!Analytics?
&debug=`1`
&isLocalhost=`1`
&excludeContextList=`content_editors`
&excludeLoggedInUserContextList=`mgr`
&displayfeatures=`0`
&enhancedLinkAttribution=`0`
&webPropertyID=`UA-XXXXX-Y`
&cookieDomain=`domain.tld`
&forceSSL=`1`
&anonymizeIP=`1`
&pagePath=`/home/landingPage`
&setAccount=`GA-XXXXX-Y`
&setDomainName=`domain.tld`
&trackPageview=`/home/landingPage`
]]
Shared Properties¶
Name | Description | Required | Default |
---|---|---|---|
debug | A simple debug mode to ouput debug messages as js comments. | no | 0 |
excludeContextList | Comma separated list of contexts to exclude from tracking - Ex: web, web2,... | no | |
excludeLoggedInUserContextList | Comma separated list of contexts to exclude from tracking when users are logged into it - Ex: mgr, web,... | no | mgr |
enhancedLinkAttribution | Enhanced Link Attribution: analytics.js, ga.js | no | 1 |
Google Universal Analytics Properties (analytics.js)¶
Name | Description | Required | Default |
---|---|---|---|
webPropertyID | trackingId parameter. | yes | |
displayfeatures | Display Features plugin. This will enable Display Advertising Features. | no | 1 |
enhancedLinkAttribution | see Shared Properties above. | no | 1 |
forceSSL | forceSSL field. | no | 0 |
anonymizeIP | anonymizeIp field. | no | 0 |
cookieDomain | cookieDomain field. | no | auto |
isLocalhost | Enable it when you want to test analytics.js from a webserver running on localhost. More… | no | 0 |
cookiePath | [deprecated] Use of this property is highly discouraged and will be removed in a future release of Analytics. | no | |
pagePath | send() Page field. | no |
Google Analytics Properties (ga.js)¶
Name | Description | Required | Default |
---|---|---|---|
setAccount | _setAccount parameter. | yes | |
enhancedLinkAttribution | see Shared Properties above. | no | 1 |
setDomainName | _setDomainName parameter. | no | |
setCookiePath | [deprecated] Use of this property is highly discouraged and will be removed in a future release of Analytics. | no | |
trackPageview | _trackPageview parameter. | no |
Want to migrate you tracking code to Universal Analytics? Consult the Universal Analytics Upgrade Center.
Different ways to set properties¶
Properties can be set in many ways: via the snippet call or properties sets, in a ressource or as a context settings.
If you set up your site settings in a resource, you can use getResourceField to retrieve the values and pass them through the snippet call.
Use your own tracking codes¶
Create your own chunks named ua_tracking
and ga_tracking
. Optionnaly use the placeholders [[+ua_options]]
and [[+ga_options]]
.
Troubleshooting¶
- Turn on debug mode.
- Make sure a tracking ID is setup with webTrackingID and/or setAccount.
- Make sure you are logged out from the manager. Remember that by default it doesn't track traffic from users logged into the manager.
Development and Bug reporting¶
Feature requests and bugs can be filed at github.
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$301 per month—let's make that $500!
Learn more