mitodl / mit-learn

BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Add data-ph- elements to CTA buttons #1821

Closed jkachel closed 2 weeks ago

jkachel commented 2 weeks ago

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:

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.