Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

seanquinn917
Copy link
Contributor

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.

@DaleMcGrew DaleMcGrew changed the title WV-986/WBV-987 Add Data Layer To "Show More" buttons on '"Fine Print" and "We Vote helps you" WV-986/WBV-987 Add Data Layer To "Show More" buttons on '"Fine Print" and "We Vote helps you" [CHANGES NEEDED] Mar 1, 2025
Copy link
Member

@DaleMcGrew DaleMcGrew left a 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',
Copy link
Member

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,
Copy link
Member

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:{
Copy link
Member

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:{
Copy link
Member

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);
Copy link
Member

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=()=>{
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants