angular-ga

WebJar for angular-ga

License

License

MIT
Categories

Categories

Angular User Interface Web Frameworks
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

angular-ga
Last Version

Last Version

0.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

angular-ga
WebJar for angular-ga
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/panrafal/angular-ga

Download angular-ga

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/angular-ga/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>angular-ga</artifactId>
    <version>0.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/angular-ga/
implementation 'org.webjars.bower:angular-ga:0.1.3'
// https://jarcasting.com/artifacts/org.webjars.bower/angular-ga/
implementation ("org.webjars.bower:angular-ga:0.1.3")
'org.webjars.bower:angular-ga:jar:0.1.3'
<dependency org="org.webjars.bower" name="angular-ga" rev="0.1.3">
  <artifact name="angular-ga" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='angular-ga', version='0.1.3')
)
libraryDependencies += "org.webjars.bower" % "angular-ga" % "0.1.3"
[org.webjars.bower/angular-ga "0.1.3"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.bower : angular jar [1.0.0,2)

Project Modules

There are no modules declared in this project.

Google Universal Analytics for AngularJS

angular-ga is a very straightforward AngularJS adapter of the new google analytics script.

It gives you full control of your analytics, exposing the google's ga() function for you. What it means is, that it will set the page field on every route change for You, but you will have to send the pageviews, events etc. manually. But on the other hand, you have the full control of that process.

Build Status

Usage

Embed tracking code

Include the new universal analytics script in your html as usual, but remove ga('send', 'pageview');

Enable the ga module

angular.module('yourModule', ['ga'])

Use ga service in your controllers, directives etc...

angular-ga service is accessible as ga. Use it exactly the same, as ga() asynchronous function:

angular.module('myModule')
    .controller('myCtrl', function (ga) {
        ga('set', 'dimension1', 'Hello!');
        ga('send', 'pageview', {title: 'Hello world!'});
    });

Use ga directive in html

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" />

By using ga-on="init" you can call ga as soon as the html is parsed:

<div ga="'send', 'pageview', {title: 'Hello world!'}" ga-on="init" />

Use ga directive's auto events

If ga attribute is empty, the event is guesses from the context as follows:

category

  • link-out if href begins with http://
  • link-in if href is anything else, except #
  • button for anything else

action

  • value of href attribute if present
  • click for anything else

label

  • value of title attribute if present
  • for input elements value of value attribute if present
  • text contents for anything else

You can use attributes ga-category, ga-action, ga-label and ga-value to override default behaviour.

githalytics.com alpha

Versions

Version
0.1.3