lahmacunradio / liquidsoap

Custom Liquidsoap script for flexible scheduling of the radio stream
7 stars 4 forks source link

Track listeners in Google Analytics #244

Closed pvj closed 3 years ago

pvj commented 4 years ago

We discussed this in person somewhat w/ @baxgas

The idea is that we could more precisely track some data about our listeners if we would set up couple of custom events for our Analytics-account.

Here's the doc: https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs#events

and an implementation example: https://evolvingweb.ca/blog/tracking-custom-events-google-analytics

Setting these up is quite straightforward and fast so we could gain lot w/ low effort. There are a number of basic cases where we currently don't know for sure our numbers since they come from Azuraland and it is quite foggy there. Stuff like:

There are some more complex cases too we could track like recurring users on certain shows, average listener time for random music vs. shows etc. but this is of course for later when we decided what to track and got accustomed to how to correctly track them.

What do you think? Let me know if more info is needed

cc @gammaw

gammaw commented 4 years ago

Very nice! In my opinion there is one thing we're desperate having: stats for live shows. These are completely missing in Azuraland. The other things we have are not bad (in Song Playback Timeline the number of joiners during a track and in Song Listener Impact the number of listeners when a track starts and those who leave during the track).

baxgas commented 4 years ago

@pvj ok, I integrated it, can go to prod

gammaw commented 4 years ago

@baxgas just checked yesterday's events from the live shows and I don't see those events in Google Analytics. Can you check?

and an implementation example: https://evolvingweb.ca/blog/tracking-custom-events-google-analytics

Did you implement this? I don't know how it works (didn't dive into it) I just realised that I don't see the ga function in our code.

baxgas commented 4 years ago

That article is outdated (2017), to my knowledge the new way is to use dataLayer.push for tracking events (more flexible and scalable)

gammaw commented 4 years ago

@baxgas ok. And what now? :) Maybe it's working and I didn't find the events. Do you have a pointer (URL) which describes the method you implemented? Can you add it to this thread?

baxgas commented 4 years ago

@gammaw check this article about the differences in Tag Manager/Analytics https://www.analyticsmania.com/post/google-tag-manager-vs-google-analytics/

baxgas commented 4 years ago

@gammaw I dived in to the issue, the ga() function didn't work out, but found this: https://support.google.com/analytics/thread/12308660?hl=en seems to work with the gtag, let's try it now image

gammaw commented 4 years ago

@baxgas thanks. It seems to be the right direction but I think we're not quite there. You use the value parameter as the main source of info (show name + live or not) but it's an integer, see documentation: https://developers.google.com/analytics/devguides/collection/gtagjs/events

The picture also shows that the value is "empty" (it's zero).

How about something like this?:

image

baxgas commented 4 years ago

@gammaw Thanks for setting up the Analytics, I'm glad we are on good track :-) I fixed the structure, can go for the test

pvj commented 4 years ago

Do we need to track whether or not something is live as the value of that datatracking?

I think that's two different things and I'm not sure whether it makes sense to track from user's perspective if what they are playing / stopping is live or not.

What do you think about this? This seems to me more intuitive, since it focuses on tracking one state whether user clicks play or stop and we record couple of other values that help us use data about this user and this state (category being show's name, action being action we're tracking etc.)

The other (live or not) could be independent of this but I'm not sure why we should be tracking this from the outside -- maybe I don't remember something?

Just thinking out loud, feel free to disregard if stupid

On Mon, Jul 6, 2020 at 8:58 AM Gaspar notifications@github.com wrote:

@gammaw https://github.com/gammaw Thanks for setting up the Analytics, I'm glad we are on good track :-) I fixed the structure, can go for the test

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mmmnmnm/lahmacun/issues/244#issuecomment-654051498, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUE6746U2FTXRYQH2ERAW3R2FY2LANCNFSM4NI7X4HA .

-- ^\^

baxgas commented 4 years ago

@pvj Thank you for the guide about the structure, I implemented it in the player

gammaw commented 4 years ago

@baxgas thanks. Looks just like we discussed. Except one thing: I thought that we want to have 1 category per show. Then, shouldn't we have song.artist as category? Your way (with song.text) we'll have the episode name as part of the event. What do you think? @pvj?

pvj commented 4 years ago

How about we track both and see what we find more useful/sensible? Maybe Geri could help at that point too?

In our discussion we talked about changing the text to artist indeed.

On Sat, 11 Jul 2020, 15:53 gammaw, notifications@github.com wrote:

@baxgas https://github.com/baxgas thanks. Looks just like we discussed. Except one thing: I thought that we want to have 1 category per show. Then, shouldn't we have song.artist as category? Your way (with song.text) we'll have the episode name as part of the event. What do you think? @pvj https://github.com/pvj?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mmmnmnm/lahmacun/issues/244#issuecomment-657066087, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUE67Y2X3YV7C72VQLFXS3R3BVE3ANCNFSM4NI7X4HA .

baxgas commented 4 years ago

@pvj @gammaw Oh, sorry, I forgot this, you are absolutely right. Changed it now, hope it can go live now :-)

gammaw commented 4 years ago

@baxgas @pvj look at that, our first stat for live shows (Aranykor és Birodalom)! :)

I guess it's not intended that we record the stats for all tracks (including off air), no? Would we want to filter them out (i.e., don't fire an event for them)?

image

baxgas commented 4 years ago

@gammaw yeah, good pointer. I'll fix it now with if/else

gammaw commented 4 years ago

@baxgas ouch, it seems like we cut the relevant part: on line shows are not recorded now (I guess they are not covered by show_check). Here's the witness for last Tuesday where the events for MMN radio live are missing (I know that there were some):

image

baxgas commented 4 years ago

@gammaw hmm, very strange, it IS checking for the live shows, at least it should from the api "show_check": function() { if ( this.np.live.is_live || (this.np.now_playing.playlist !== 'OFF AIR' && this.np.now_playing.playlist !== 'Off Air Ambient' && this.np.now_playing.playlist !== 'Jingle' && this.np.now_playing.playlist !== 'Jingle AFTER SHOW' && this.np.now_playing.playlist !== '') ) { return true; } else { return false; } }, This check is also used for ON AIR banner and others, so if it returned false, the ON AIR banner was also missing

gammaw commented 4 years ago

@baxgas I think I know what's going on. Even in case of live shows we use this.np.now_playing.song.artist as event category. The problem is that it's not the artist in this case. I think, in this case we need to use this.np.live.streamer_name. You can check the code for details, e.g.,

https://github.com/mmmnmnm/lahmacun/blob/3a4782029e8d97dc7d35c349a45c43d45eb3aae9/wp/wp-content/themes/lahma_maker/assets/playerfiles/radio_player.vue#L239-L244

baxgas commented 4 years ago

@gammaw oh, you are right, completely forgot about this. I changed the tag to show_title now, seems to be working