revolunet / angular-google-analytics

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

Advanced setting: User-ID #134

Open fkusztos opened 8 years ago

fkusztos commented 8 years ago

I can not to set the user id tracking. I tried two ways: 1- as the readme says, I tried

Analytics.set('&uid', 1234);

2- as the analytics doc says, I tried

Analytics.set('userId', 1234);

But I can not see anything on the "Network" outputs, neither than on the GA interface. (note that the GA account is properly set up) Is anyone uses this functionality?

Thanks

Version used: 1.1.5

justinsa commented 8 years ago

Hey @fkusztos, after you set a value you have to call the PageView function in order to send the changes. If you didn't do that then please try that to see if it corrects your issue. Otherwise, you have two options now for debugging, both of which are explained in the README and can be very helpful for diagnosing. GA has internal logic for when it batches and sends commands.

that1guy commented 8 years ago

Exact same issue here:

I've tried userId, $userId, uid, &uid. Never gets appended to GET req.

app.run(['$rootScope', 'userFactory', 'Analytics', function($rootScope, userFactory, Analytics) {

    $rootScope.user = userFactory.user.data;
    Analytics.set('userId', 1234);
    Analytics.pageView();

ga

asaarnak commented 8 years ago

this._set = function (name, value, trackerName) { should support also _gaMultipleTrackers

justinsa commented 8 years ago

@asaarnak I have created an enhancement request for your suggestion: #138

asaarnak commented 8 years ago

Thanks, 1 more thing i stumbled upon is Analytics.trackPage where i wanted to track by tracker name. But by default it tracks all trackers and can't override it.

that1guy commented 8 years ago

@justinsa, slightly confused here. Is there a solution yet to the original issue this ticket describes that I expanded on, or am I doing something wrong? Thanks!

theseanstewart commented 8 years ago

@that1guy I was having the same issue as you and it's because I was setting the name of my tracker in AnalyticsProvider.setAccount.

AnalyticsProvider.setAccount([
      {
        tracker: 'UA-XXX',
        name: 'tracker1',
        displayFeatures: true,
        enhancedLinkAttribution: true
      }
    ]);

After removing name: 'tracker1', it started working properly.

This is mentioned in the docs, but it wasn't very obvious. Hope it helps!

justinsa commented 8 years ago

@that1guy did @theseanstewart's comment resolve your issue? There is a big difference between the default tracker (which is an unnamed tracker) and all of the named trackers. If you are using the set function with a named tracker you have to call it with the tracker name: Analytics.set('&uid', 123, 'tracker1');. I purposefully made set not define the value for all trackers because that removes the flexibility to set custom values for different trackers.

that1guy commented 8 years ago

@justinsa I'm still not seeing expected result here. I see the &uid being appended to GA GET requests (I've even added a custom dimension with the same user id).

image

Here we are in logged in to Google Analytics and I've never seen a user logged in.

image

Everything is working though if I change into different view.

image

Filtering all data by dimension doesn't seem to work either.

image

JeremyBYU commented 8 years ago

Same Issue at @that1guy. I can see my requests are sending the id to ga, but the user view in google analytics is not showing them. Not sure if its google analytic issue or this packages issue.

UPDATE: Google analytics just started tracking users. Must have just taken a few hours. Only showing up in the Real-time feed, not the audience feed.

that1guy commented 8 years ago

We have resolved this issue. It was a configuration error with Google Analytics.

armyofda12mnkeys commented 7 years ago

Hey all, just to confirm about adding GA's 'userId' to track a true session in a Single Page angular App: I should add: Analytics.set('&uid', '10101234'); and when should i set this when sending up page-views? Like right now I manually send ga pageviews and custom dimensions on certain routes to Google via: Analytics.trackPage(url, title, dimensions); on certain Controllers. so Should I set it via that Analytics.set() method always before or after the manual trackPage() method?

Another question... Should I only set it once or doesn't really matter; like can have I set always before (or after, based on answer above) that Analytics.trackPage() method, and angular-google-analytics (and GA) will know what to do? It would be cool if it doesn't matter and smartly knows its the same user/session (since I could put it in my 'get next question' controller which might have trouble figuring out if the current question is the 1st question to dynamically add that line).

ViieeS commented 7 years ago

@armyofda12mnkeys Analytics.set('&uid', '10101234'); - not working for me... don't see it in network tab UPD: working pattern https://github.com/revolunet/angular-google-analytics/issues/175#issuecomment-272894671

splNovikov commented 7 years ago

Same issue. Tried different things: .run(['Analytics', function (Analytics) { Analytics.trackEvent('Page loaded'); Analytics.set('&uid', userId); // also tried 'userId' Analytics.pageView(); }]);

Doesn't help.

ChristianArredondo commented 6 years ago

@that1guy What was the configuration error?