Skip to content

UseAllFive/marionette.googleAnalyticsEvents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

marionette.

googleAnalyticsEvents

Brought to you by Use All Five, Inc.

Author: Justin Anastos <janastos@useallfive.com>
Author URI: [http://www.useallfive.com](http://www.useallfive.com)
Repository: https://github.com/UseAllFive/marionette.googleAnalyticsEvents

Scope

Trigger Google Analytics event and route calls from Marionette views/routes.

Functionality

Routes

Routes will automatically call a route navigate event like so:

ga('send', 'event', 'route', 'navigate', '/some/deep/link');

No configuration is necessary for the routing events to be sent.

Events

Marionette views can have an extra parameter added to each trigger object to make it automatically track with Google Analytics.

For example:

var view = Marionette.ItemView.extend({
    ui: {
        someButton: '.someButton'
    },
    triggers: {
        'click @ui.someButton': {
            event: 'eventToPropogate',
            googleAnalyticsConfig: {
                category: 'some category',
                event: 'some event',
                label: 'optional. some label'
            }
        }
    }
});

When the UI element is triggered, then the following will be called:

`ga('send', 'event', 'some category', 'some event', 'optional. some label');

The googleAnalyticsConfig triggers option can also be a function that returns an object like this:

var view = Marionette.ItemView.extend({
    ui: {
        someButton: '.someButton'
    },
    triggers: {
        'click @ui.someButton': {
            event: 'eventToPropogate',
            googleAnalyticsConfig: function() {
                return {
                    category: this.model.get('something'),
                    event: 'some event',
                    label: 'optional. some label'
                };
            }
        }
    }
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published