okgrow / analytics

UNMAINTAINED! - Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor
https://atmospherejs.com/okgrow/analytics
MIT License
213 stars 61 forks source link

Setup google analytics track event with custom data #181

Closed townmulti closed 7 years ago

townmulti commented 7 years ago

When I visit Google Analytics dashboard I see that my event labels and values are not being set. The event actions are set correctly in the dashboard. I have not put autorun: false in my settings file.

This is how I'm calling track within a meteor Validated Method:

     if (Meteor.isClient) {
         analytics.track('USER USED FEATURE', { category: "Feature Usage", label: this.userId, value: 1 }));
     }

I can see the correct data coming over when I put this in the root react constructor:

    analytics.on("track", (event, properties, options) => {
      console.log(event, properties, options);
    });

How should I form my tracking call in my method so that the data carries over to google?

cfnelson commented 7 years ago

@townmulti Where in your Validated Method do you have the track being called? And you confirm that the method is running on the client and triggering the analytics.track()?

I would suggest moving the analytics.track() out of the method and first test if you are in-fact receiving the event. You can also call analytics.debug() in your console and do a refresh to get debugging to show in your console.

You can read more about analytics.track() here. Your code looks correct except for the typo at the end, you have an extra ).

townmulti commented 7 years ago

Thanks! I see the events and labels showing now.