segmentio / segmentio/analytics.js-integrations
google-tag-manager add identify properties to dataLayer
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 125
- Forks
- 136
- Avg merge
- 2h 45m
- Merged PRs (30d)
- 1
Description
Hi,
Currently the Segment identify method does not push any user properties to the GTM data layer. Should it?
in the app code
window?.analytics?.identify('userId123', {
account: '12345678',
contact: 'john.smith@company.com',
});
but when you console.log the window.dataLayer, you only have the page event which is missing the user properties like account and contact
[{
event: "Loaded a Page"
gtm.uniqueEventId: 1
path: "/blah"
referrer: "blah"
search: ""
segmentAnonymousId: "123123123"
title: "blah"
url: "blah"
userId: "userId123"
}]
This means if I want to use the account property as a dataLayer variable in GTM then I need to explicitly call an eventless track on page load with it, or inject it into the dataLayer manually.
Both approaches seem to go against the Segment best practice.
What should the expected behaviour be?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Segment identify call shown in the issue and inspect window.dataLayer in the Google Tag Manager integration. First determine the intended identify-to-dataLayer behavior and review existing integration entry points and tests, which the issue does not name. Done should define and verify how account and contact become available without an eventless track or manual dataLayer injection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- analytics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100