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

Track Theme popularity through Google Analytics #213

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Track Theme popularity through Google Analytics #213

wants to merge 3 commits into from

Conversation

FrontEndCoffee
Copy link
Contributor

Fixes #50

This solution detects a CTRL+C or CMD+C keypress inside the copy section, and dispatches an event to Google Analytics, where the events can be categorised and such.

This solution is not perfect. Copying events through mouse clicks are not covered, and multiple copy events also trigger multiple GA events. I think that even though these imperfections are there, the data can still show interesting trends through the discrepancies.

Feel free to add feedback @paracycle

@paracycle
Copy link
Owner

This is a great attempt, but I was more thinking of tracking how many times each theme was viewed as (synthetic) page views. We could track how many times theme colours were copied as well, but tbh that is a secondary concern for me.

If we could get https://github.com/googleanalytics/autotrack integrated into the project and start sending out URL Change events as themes are being switched at this point, it would be great.

@FrontEndCoffee
Copy link
Contributor Author

@paracycle correct me if I'm wrong, but doesn't googleanalytics/autotrack send GA events at the end of the day?

All the relevant events can be dispatched from the ThemeController, because we already have te ga() function available.

I would much prefer this implementation compared to pulling in autotrack, as it is an extra dependency that increases load time etc.

tl;dr: with under 10 lines of extra code we can accomplish the things you want without using autotrack.

@paracycle
Copy link
Owner

Yeah, sure, autotrack is not a hard requirement. Also, autotrack does not handle SPA with hash-fragments automatically:

Note: this plugin does not support tracking hash changes as most Google Analytics implementations do not capture the hash portion of the URL when tracking pageviews.

I am all for using the built-in ga() functionality though. It would be great if we could limit the "theme popularity" to just pageviews as part of this PR and maybe consider copying as a separate thing to think about.

What do you think?

@FrontEndCoffee
Copy link
Contributor Author

It would be great if we could limit the "theme popularity" to just pageviews as part of this PR and maybe consider copying as a separate thing to think about.

It think it's a great starting point! Just to be clear:

  • Do you propose a user landing on a theme by a browser link counts as a theme view
  • Or do you propose a user clicking on a theme counts as a theme view
  • Or both?

@paracycle
Copy link
Owner

Thanks for being so meticulous, I appreciate it.

Ideally I would like to capture all view landings as page views, so both browser links (in case people have shared links with their friends) and clicks. The spanner is the works is the initial redirect to the first theme in the list. If we keep counting that, it will skew the results. However, I am not sure how to exclude that first rewrite.

Do you think you can take a stab at it?

@FrontEndCoffee
Copy link
Contributor Author

I can try 😉

@FrontEndCoffee
Copy link
Contributor Author

@paracycle you should test it locally with your google analytics token configured, but it should work!

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