Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Conversation

aaimio
Copy link
Contributor

@aaimio aaimio commented Apr 22, 2019

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.0%) to 73.58% when pulling a7afec6 on aaron-binary:pass-visitorid-to-gtm into 5ddba6b on binary-com:dev.

const setVisitorId = () => {
const tokenList = getTokenList();
if (tokenList.length > 0) {
pushDataLayer({ visitorId: tokenList[0].loginInfo.loginid });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the client switched the account from the dropdown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the client switched the account from the dropdown?

The token list in local storage reflects the same order as can be seen in the dropdown, so the 0 index will always be the account that's active. The setVisitorId function is called on both account switch & logout, so it would pass the correct visitorId to the data layer.

if (tokenList.length > 0) {
pushDataLayer({ visitorId: tokenList[0].loginInfo.loginid });
} else {
pushDataLayer({ visitorId: undefined });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if pushing undefined is necessary

Copy link
Contributor Author

@aaimio aaimio Apr 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user logs out and visitorId isn't set to undefined, it would still register clicks as the most previous logged in user.

@ashkanx ashkanx merged commit a09fe8f into binary-com:dev Apr 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants