revolunet / angular-google-analytics

Google Analytics tracking for your AngularJS apps
MIT License
652 stars 179 forks source link

Not working... Help with setting up. #207

Closed lastlink closed 6 years ago

lastlink commented 6 years ago

This is what I've done so far: export default function config(...., AnalyticsProvider) { AnalyticsProvider .logAllCalls(true) .startOffline(true) .useAnalytics(false) .useDisplayFeatures(true) .useEnhancedLinkAttribution(true); AnalyticsProvider.setAccount('trackingid');

... }

.config(config) .run(['Analytics', function(Analytics) { Analytics.registerScriptTags(); Analytics.registerTrackers(); console.log(Analytics.configuration) }]);

I seem to figure out why the tracking is not working at all on the website. Is there something here that I'm missing?

I already inject AnalyticsProvider into the module and no errors come from it not existing. When I check google analytics panel with this tracking id it still tells me 0 active users on site.

lastlink commented 6 years ago

update- this worked for me: I didn't need to do the .run([analytics..., but each view controller needed this Analytics.trackPage($location.$$path, $state.current.data.pageTitle); I also removed .startOffline(true), this would be more applicable for cordova hybrid apps.

justinsa commented 6 years ago

@lastlink The problem was using .startOffline(true). Nothing will be sent if the service is in offline mode. It is just queued in-memory waiting to be put into online mode. Offline mode is turned off when you call the service after configuration with: Analytics.offline(false); Registering the script tags and trackers does not take the service out of offline mode.

Also, you should remove the .logAllCalls(true) method when you release your code. That method creates an in-memory queue of all calls for testing and debugging purposes.