Applying the Adapter Pattern for Analytics in Ember.js Apps
Lauren Elizabeth Tan

Hi Lauren, thanks for this clear and useful article. I want to add a google analytics event tracker in a controller. My example code is below. But it did’t work. What is the best practice of that, could you help me? I want to trigger that event when action called.

import Ember from 'ember';
import config from '../config/environment';
export default Ember.Controller.extend({
metrics: Ember.inject.service(),
actions: {
someAction() {
this.get('metrics').trackEvent('GoogleAnalytics', {
hitType: 'event',
eventCategory: 'Videos',
eventAction: 'play',
eventLabel: 'Fall Campaign'