-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically changing account ID after App init #175
Comments
FYI i was able to do something like this to change the account info.
and in my 'run'
proabably not the best way to do it but it works :) |
@29er Yeah, you figured out the way to do it that circumvents the config stage. This is purposefully mentioned in the README as unsupported because it should change in the future to prevent such monkeying with the configuration object post config phase. The suggested way to do this is to pre-load the configuration from the server prior to starting angular. I do see the merit though in exposing some configuration methods during the run phase if the 'delayScriptTag' was set to true. These extra configuration methods would then produce exceptions if called after the 'createAnalyticsScriptTag' was called. |
Working pattern: AnalyticsProvider
.setAccount('UA-XXX-defaultID')
.delayScriptTag(true);
.ignoreFirstPageLoad(true);
app.run([ 'someService', 'Analytics', function(someService, Analytics) {
someService.getAccount(resp => {
if(expression){
// change default tracker if you need it
Analytics.configuration.accounts[0].tracker = resp.acct
}
Analytics.registerScriptTags();
Analytics.registerTrackers();
if(resp.userID){
// you can set any advanced configuration here
Analytics.set('&uid', resp.userID);
}
Analytics.pageView(); // send data to Google Analytics
}]); |
If you are doing manual bootstrapping of your application you have access to the injector and therefore
|
Hi,
In my current setup, we don't know the Account (tracking id ) until we make a request to get environment info. So I need to wait to set the Account until after the app initializes, ( I do not have access to $http in a 'config' )
ie:
So I need to be able to do something like this below. (but it won't work because 'setAccount' is not a function of Analytics) And if I try to manipulate the Analytics.configuration.accounts, it still gives me the #error
"No account id set to create analytics script tag" and analytics does not work
This is essentially what Im trying to achieve
Thanks for any advice!
The text was updated successfully, but these errors were encountered: