Skip to content

🎧 Your Personal Streaming Service

Send play song event to GA

Deluan865bad155043
diff --git a/ui/src/audioplayer/Player.js b/ui/src/audioplayer/Player.js
index 50a53a2ee..944d6c63a 100644
--- a/ui/src/audioplayer/Player.js
+++ b/ui/src/audioplayer/Player.js
@@ -1,4 +1,5 @@
import React, { useCallback, useMemo } from 'react'
+import ReactGA from 'react-ga'
import { useDispatch, useSelector } from 'react-redux'
import { Link } from 'react-router-dom'
import { useAuthState, useDataProvider, useTranslate } from 'react-admin'
@@ -8,6 +9,7 @@ import subsonic from '../subsonic'
import { scrobble, syncQueue, currentPlaying, setVolume } from './queue'
import themes from '../themes'
import { makeStyles } from '@material-ui/core/styles'
+import config from '../config'
const useStyle = makeStyles((theme) => ({
audioTitle: {
@@ -134,6 +136,13 @@ const Player = () => {
document.title = `${info.name} - ${info.singer} - Navidrome`
dispatch(scrobble(info.trackId, false))
subsonic.scrobble(info.trackId, false)
+ if (config.gaTrackingId) {
+ ReactGA.event({
+ category: 'Player',
+ action: 'Play song',
+ label: `${info.name} - ${info.singer}`,
+ })
+ }
}
},
[dispatch]