angular-google-analytics icon indicating copy to clipboard operation
angular-google-analytics copied to clipboard

Advanced setting: User-ID

Open fkusztos opened this issue 8 years ago • 15 comments

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

fkusztos avatar Jan 14 '16 16:01 fkusztos

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.

justinsa avatar Jan 23 '16 20:01 justinsa

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

that1guy avatar Jan 25 '16 23:01 that1guy

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

asaarnak avatar Feb 02 '16 15:02 asaarnak

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

justinsa avatar Feb 03 '16 08:02 justinsa

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.

asaarnak avatar Feb 03 '16 08:02 asaarnak

@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!

that1guy avatar Feb 03 '16 09:02 that1guy

@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!

theseanstewart avatar Feb 03 '16 17:02 theseanstewart

@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.

justinsa avatar Feb 20 '16 05:02 justinsa

@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

that1guy avatar Mar 28 '16 22:03 that1guy

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.

JeremyBYU avatar May 05 '16 14:05 JeremyBYU

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

that1guy avatar May 05 '16 18:05 that1guy

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).

armyofda12mnkeys avatar Sep 29 '16 17:09 armyofda12mnkeys

@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

ViieeS avatar Jan 16 '17 16:01 ViieeS

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.

splNovikov avatar Apr 26 '17 11:04 splNovikov

@that1guy What was the configuration error?

ChristianArredondo avatar Aug 01 '18 15:08 ChristianArredondo