-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WV-986/WBV-987 Add Data Layer To "Show More" buttons on '"Fine Print" and "We Vote helps you" [CHANGES NEEDED] #4265
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @seanquinn917!
// console.log("Show More clicked (tracked):", showMoreId); | ||
// const eventName = showMoreCustomText || 'show more'; | ||
const dataLayerObject = { | ||
event: 'Show More Button Clicked', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we want "event" to be a camelCase event name we can listen for in GTM, instead of a sentence.
// const eventName = showMoreCustomText || 'show more'; | ||
const dataLayerObject = { | ||
event: 'Show More Button Clicked', | ||
element_id: showMoreId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add "element_id" to the pageDetails dictionary. Please also make it camelCase.
const dataLayerObject = { | ||
event: 'Show More Button Clicked', | ||
element_id: showMoreId, | ||
source:{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please convert "source" to "pageDetails".
pageType: "homepage", | ||
pathName: window.location.pathname, | ||
}, | ||
user:{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change "user" to "userDetails".
// console.log("dataLayerObject:", dataLayerObject) | ||
TagManager.dataLayer({ dataLayer: dataLayerObject }); | ||
} else if (trackInGTM && showMoreButtonWasClicked){ | ||
console.log("Show Less clicked (not tracked):", showMoreId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only indent by 2 spaces instead of 3. I think we should track "show less" clicks.
|
||
|
||
class ShowMoreButtons extends React.Component { | ||
handleClick=()=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the generic function name handleClick
to a function name that tells other programmers what this function is doing. For example sendDataToGTMAndNotifyParent
.
Add Google Tag Manager data layer to two "Show More" instances: "fine print" and "we vote helps you.
Specific logic changes include passing props from ReadyIntroduction.jsx and ReadyFinePrint.jsx components to create the instances where GTM fires. Adding "trackInGTM={true}" down to other Show more instances will create data layers in those as well if future needs require.