Track Theme popularity through Google Analytics
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
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.
@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.
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?
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?
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?
I can try 😉
@paracycle you should test it locally with your google analytics token configured, but it should work!