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

[Scorecards] Added click tracking for graphics #692

Closed
wants to merge 4 commits into from

Conversation

lucascumsille
Copy link
Contributor

@lucascumsille lucascumsille commented Sep 11, 2024

Fixes: #688

We are tracking:

  • Section
  • File type
  • if user is clicking an image then we also track which ratio

@lucascumsille
Copy link
Contributor Author

@zarino thanks for all the help when creating the issue. I'm not sure how to test it though, I added some console logs before to check if we were gathering correctly the params, event name and callbacks, and it seems to be working fine.

I split the fileType and imgRatio, but we could have merged those two together, I think because they are two separate things it makes sense to keep them separate, but I'm not to fuzzy about either option.

Copy link
Member

@zarino zarino left a comment

Choose a reason for hiding this comment

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

Thanks @lucascumsille! A couple of small comments inline.

Although—crazy thought—I wonder whether we even need to be recording section, fileType and imgRatio separately, when we could just track the URL of the image the user is downloading? 🤔 Wonder whether that might be simpler.

If you want to test this out, you should theoretically be able to do it by putting a valid Google Analytics Gtag ID (doesn’t matter which, can be a live account, GA will ignore the events because they’re not coming from the right domain) into a GOOGLE_ANALYTICS_SCORECARDS environment variable in your .env file, and then using a browser extension like this to intercept/log the gtag calls (or, without an extension, you’ll still be able to see the calls being made, as Network requests, in your built-in browser tools).

scoring/static/scoring/js/main.js Outdated Show resolved Hide resolved
scoring/static/scoring/js/main.js Outdated Show resolved Hide resolved
scoring/templates/scoring/section.html Outdated Show resolved Hide resolved
@lucascumsille
Copy link
Contributor Author

Thanks for the feedback @zarino 🙌

Regarding the following comments:

Although—crazy thought—I wonder whether we even need to be recording section, fileType and imgRatio separately, when we could just track the URL of the image the user is downloading? 🤔 Wonder whether that might be simpler.

I thought we were making the split between the different properties because it had an impact for the person checking the clicks, but if it doesn't have any practical benefit then I would go for the simple solution. Let me know if you have any preference regarding this.

I’m slightly worried this is a bit fragile if we happened to change the URL pattern, and some missing data in GA would go easily unnoticed. Since we’re pulling lots of other data out of custom attributes on the elements, maybe we should do the same here?

Good point! I tried finding how we pull the section codes on a section page, I couldn't find anything there, except by the canonical_url bit. I'm sure we can add something to sectionView if we wanted to add it as an attribute. In the meantime I have replace the section by the current page url, which gives up the section code.

@zarino
Copy link
Member

zarino commented Sep 11, 2024

Let me know if you have any preference regarding this.

My instinct is simpler is better. There won’t be a huge number of events here, and if somebody really wanted to split out the filetypes and aspect ratios, they could do it from the image URLs.

But maybe check that just recording the URLs of the images, and how often they’ve been downloaded, is good enough for CEUK? Since they’re the ones that asked for the tracking in the first place :-)

@lucascumsille
Copy link
Contributor Author

@zarino at the end we will be using only the url as parameter, considering that it also displays:

  • section
  • File type
  • Image ratio

Copy link
Member

@zarino zarino left a comment

Choose a reason for hiding this comment

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

👍 🎉

@lucascumsille
Copy link
Contributor Author

Closed via 97b851c

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.

Track clicks on section page infographic / social graphic download buttons
2 participants