Overview of changes
As below, but I believe it was chosen not to use, or abandoned or something, because the current GTM configuration does not seem to have any active triggers used.
- Using the module
angular-google-analytics
defined invendor_custom/angular-track/index.js
, - which defines the
Analytics
service, - which is subsequently programmatically used as follows:
- on each state change, if logged in, sets (
Analytics.set(KEY, VALUE)
)&uid
to the (hashed) user iddimension1
to the user status (user.identity.status
)dimension3
touser.identity.numberOfBookings
dimension4
touser.identity.preference
- at specific moments, programmatically triggers analytics events via
-
Analytics.trackEvent(category, action, label, value, noninteraction, custom_extra_fields)
-
- on each state change, if logged in, sets (
- and it also listens to
$rootScope.on('$routeChangeSucces')
, at which point a page view event is triggered.
This is done manually, with
- the provider
googleTagManager
in theopenwheels.analytics
module insrc/app/analytics/analytics.js
, - the configuration (setting of the GTM code) of this provider in the main
app.js
file.
The Angulartics package,
- defines the
angulartics
module, - provides the (confusingly named)
$analytics
service, - only provides a the Angular infrastructure (directives, service, etc), as follows:
- being able to detect scroll (if you want to)
- the
analytics-event
/analytics-on
directives (and some more) $analytics.pageTrack(URL)
-- and also automatically registers virtual page tracks (via$rootScope.$on('$routeChangeSuccess')
)-
$analytics.eventTrack(EVENT_NAME, { category, label, ... })
The angulartics-google-tag-manager
package
- defines the
angulartics.google.tagmanager
module, - doesn't provide anything,
- and just delegate Angulartics' page views and events to
dataLayer.push
es. - No registration, it just pushes to the global variable
dataLayer
. $analytics.eventTrack(EVENT_NAME, { category, label, event, value, noninteraction })
leads todataLayer.push({ 'event': event || 'interaction', 'action' : EVENT_NAME, 'target': category, 'target-properties': label, 'value': value, 'interaction-type': noninteraction, 'userId': $analyticsProvider.settings.ga.userId, });
$analytics.pageTrack(path)
leads todataLayer.push({ 'event': 'content-view', 'content-name': path, 'userId': $analyticsProvider.settings.ga.userId, });
GTM must be configured correctly to broker the page views and events to e.g. Google Analytics.
Following the naming choices of angulartics-google-tag-manager
, which provides a default importable container with 2 pre-configured tags, 2 triggers, and a load of variables:
- Tags
- "Angulartics Event", which sends an "event" track type event to Analytics
- "Angulartics Pageview", which sends a "pageview" track type event to Analytics, with associated data
- Triggers
- "Angulartics event" -- specifically, this checks for (dataLayer)
event === 'interaction'
- "Angulartics pageview" -- specifically, this checks for (dataLayer)
event === 'content-view'
- "Angulartics event" -- specifically, this checks for (dataLayer)
- Variables
- ...