Skip to content

Add data-ph- elements to CTA buttons #1821

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

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

jkachel
Copy link
Contributor

@jkachel jkachel commented Nov 12, 2024

What are the relevant tickets?

https://github.com/mitodl/hq/issues/5989

Description (What does it do?)

We need a clear way to identify when users click on the CTA button in the Learning Resource drawer - this adds that, in the form of data-ph- attributes.

The attributes that are added are:

  • data-ph-action - set to click-cta (this is the standard PostHog attribute we decided on)
  • data-ph-offered-by - set to the offeror code
  • data-ph-resource-type - set to the resource type
  • data-ph-resource-id - set to the resource ID

These are added to both the V1 and V2 LearningResourceExpanded components since the v2 one isn't rolled out yet.

How can this be tested?

This does not handle video resources - videos will require more work (due to the CTA being the embedded video itself). So, choose resources that aren't videos. These will be handled in a future PR.

The easiest way to test this is to create an Action in PostHog's Data Management tab. Set up an Action that has one Match Group. The Match Group should be set to Autocapture and the "Element matches HTML selector" should be set to [data-ph-action="click-cta"].

Then, load some resources and click the CTA buttons in the drawers. You should see events match in the Action after some delay.

@jkachel jkachel added Needs Review An open Pull Request that is ready for review product:mit-open Issues related to the MIT Open product labels Nov 12, 2024
@shanbady shanbady self-requested a review November 13, 2024 14:35
@shanbady shanbady self-assigned this Nov 13, 2024
@@ -285,7 +285,7 @@ const getCallToActionText = (resource: LearningResource): string => {
const accessCourseMaterials = "Access Course Materials"
const watchOnYouTube = "Watch on YouTube"
const listenToPodcast = "Listen to Podcast"
const learnMore = "Learn More"
const learnMore = "Learn More About"
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 assuming V2 isnt displayed anywhere yet. was this copy change intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was not, fixed in bb7bd02

@jkachel jkachel requested a review from shanbady November 13, 2024 15:21
@shanbady shanbady added Waiting on author and removed Needs Review An open Pull Request that is ready for review labels Nov 13, 2024
@jkachel jkachel merged commit 2942fac into main Nov 13, 2024
11 checks passed
@jkachel jkachel deleted the jkachel/5989-add-event-to-cta-button branch November 13, 2024 16:34
This was referenced Nov 14, 2024
mbertrand pushed a commit that referenced this pull request Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:mit-open Issues related to the MIT Open product Waiting on author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants