revolunet / angular-google-analytics

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

AnalyticsProvider configuration does not persist into Analytics instance #212

Closed engageft3 closed 6 years ago

engageft3 commented 6 years ago

Good morning,

I'm currently attempting to use version 1.1.8 with Angular 1.5.8 and have this block for setting everything up:

angular.module('app', ['angular-google-analytics'])
.config(['AnalyticsProvider', (AnalyticsProvider) => {
        let location = window.location.origin;

        AnalyticsProvider
            .setDomainName(location)
            .setAccount(
                [
                    {
                        tracker: 'UA-XXXXXXXX-X',
                        displayFeatures: true,
                        enhancedLinkAttribution: true
                    }
                ]
            )
            .useAnalytics(true)
            .useECommerce(true, true)
            .trackPages(true)
            .setCurrency('CAD')
            .setPageEvent('$stateChangeSuccess');
    }]).run(['Analytics', '$rootScope', (Analytics, $rootScope) => {
        $rootScope.analytics = Analytics;
    }]);

When logging $rootScope.analytics the configuration still has everything set to the default values.

Any help with this would be greatly appreciated, thank you in advance.

revolunet commented 6 years ago

so what happened please ?

engageft3 commented 6 years ago

I had environment-specific code that returned early in the function block that I did not post as part of my gist. My apologies, this is now resolved.

revolunet commented 6 years ago

all good, thanks 👍