Google Analytics - Match UserID with my site's account ID

后端 未结 1 1020
自闭症患者
自闭症患者 2021-01-07 11:23

Each of my registered clients have an unique account ID (eg: agent n°: 00173393).

I want to retrieve this information through google analyti

相关标签:
1条回答
  • 2021-01-07 12:12

    Why don't you use the account ID as User ID as well? That way you would have a 1-to-1 match:

    ga('create', 'UA-XXXXX-Y', 'auto', {
      userId: accountId
    });
    

    Please note however that the User ID is not exposed back by Google Analytics. If you want to retrieve it, you need to save it inside a custom dimension:

    • Admin -> Property -> Custom Dimensions -> Create one with User scope
    • Add custom dimension tracking to your code

    For instance:

    ga('create', 'UA-XXXXX-Y', 'auto', {
      userId: accountId,
    });
    ga('set', 'cd1', accountId); // if it's custom dimension n1
    ga('send', 'pageview');
    

    Then you can retrieve the User ID via the UI:

    or the API

    0 讨论(0)
提交回复
热议问题