This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
forked from ualib-deploy/roots-ualib
-
Notifications
You must be signed in to change notification settings - Fork 3
Directives
Will Jones edited this page Jun 15, 2016
·
1 revision
A modified version of the angular-ga module, the
ga
directive helps easily bind Google Analytics events to HTML elements.
Use ga directive in html (from the angular-ga docs)
Contents of the directive should be the array of parameters for ga()
function.
You can skip the enclosing array '[]' if you start with the single-quote character.
Of course, you can use angular expressions, as this is evaluated.
Both samples are equivalent to calling ga('send', 'event', 'player', 'play', video.id)
on the click
event:
<a href="#" ga="'send', 'event', 'player', 'play', video.id"></a>
<a href="#" ga="['send', 'event', 'player', 'play', video.id]"></a>
You can call ga
several times by passing an array of arrays:
<a href="#" ga="[['set', 'metric1', 10], ['send', 'event', 'player', 'play', video.id]]"></a>
You can change the event by providing ga-on
attribute:
<input type="text" ga="'send', 'event', 'focus'" ga-on="focus" />