Skip to content

Statistics Integration

By , Customer Success DirectorUpdated

Open this page in a new chat

Short answer

Sirv JS sends statistics to stats.sirv.com when people use a gallery or spin, such as sessionStart, rotate, zoomIn and fullscreenOpen. You can see each request in your browser console. Collect the data in Google Tag Manager, or add a script that listens for the stats events and sends them to your own analytics.

After reading this you will know

  • Which statistics Sirv JS sends
  • How to collect them with Google Tag Manager or your own script

You can hook into statistics sent by Sirv JS when users interact with a gallery or a spin. To run your own code on viewer actions, use Media Viewer events.

If you open your browser console, you will see all stats requests as they are triggered in the “Console” section. Each statistic is sent to stats.sirv.com and you can also collect that data.

An easy way to collect the data is via Google Tag Manager. Read the article to track 360 spins with Google Tag Manager and import them to an analytics platform.

You can listen for stats events by adding this script to your page:

document.addEventListener('sirv:viewer:stats', e => {
console.log(e.detail.statsData);
});

Example of the data returned in the sessionStart stats event:

e.detail.statsData = {
browser: {
width: 892,
height: 823
},
screen: {
width: 1512,
height: 982,
availWidth: 1512,
availHeight: 950,
colorDepth: 30,
pixelDepth: 30
}
name: "sessionStart",
origin: "///sirv.sirv.com/website/demos/vivo/vivo-hotspots.spin",
sessionId: 3415941547,
ts: 1757498189424,
type: "spin"
};

sessionStart - returns information about the browser, screen and session.

statsData: {
data: {
browser: {
width: Number,
height: Number
},
screen: {
availHeight: Number,
availWidth: Number,
width: Number,
height: Number,
colorDepth: Number,
pixelDepth: Number
},
},
name: String, // sessionStart - statistics type name
origin: String, // url path of spin
sessionId: Number,
ts: Number, // timestamp Date.now()
type: String // spin - component type
}

sessionEnd - when the Sirv Media Viewer instance is destroyed.

statsData: {
data: {
message: String // Stopped
},
name: String, // sessionEnd - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

framesPreloaded - the initial 360 spin images have loaded (spin can be used, whilst remaining images load seamlessly in background).

statsData: {
data: {
duration: Number // time in milliseconds from start of session to current moment
},
name: String, // framesPreloaded - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

viewerReady - the Sirv Media Viewer instance is ready for interaction.

statsData: {
data: {
columns: Number,
rows: Number,
viewerSize: {
width: Number,
height: Number
}
},
name: String, // viewerReady - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

framesLoaded - all images have loaded.

statsData: {
data: {
duration: Number // time in milliseconds from start of session to current moment
},
name: String, // framesLoaded - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

dragStart - the user grabbed the spin to start rotation - triggered by drag, mouse-scroll or API rotate.

statsData: {
data: {
clientX: Number,
clientY: Number,
pageX: Number,
pageY: Number
},
name: String, // dragStart - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

rotate - the spin is rotating.

statsData: {
data: {},
name: String, // rotate - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

dragEnd - the user released the spin.

statsData: {
data: {
clientX: Number,
clientY: Number,
pageX: Number,
pageY: Number,
duration: Number // time in milliseconds from dragStart to the current moment
},
name: String, // dragEnd - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

fullscreenOpen - when user opens fullscreen mode.

statsData: {
data: {},
name: String, // fullscreenOpen - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

fullscreenClose - when user closes fullscreen mode.

statsData: {
data: {
duration: Number // time in milliseconds from start of session to current moment
},
name: String, // fullscreenClose - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

zoomIn - when user zooms in to an image.

statsData: {
data: {
clientX: Number,
clientY: Number,
pageX: Number,
pageY: Number,
frame: {
row: Number,
column: Number
}
},
name: String, // zoomIn - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

zoomOut - when user zooms out of an image.

statsData: {
data: {
clientX: Number,
clientY: Number,
pageX: Number,
pageY: Number,
duration: Number, // time in milliseconds from start of session to current moment
frame: {
row: Number,
column: Number
}
},
name: String, // zoomOut - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

Page Unload - when the user closes the page.

statsData: {
data: {
message: String // Stopped
},
name: String, // Page Unload - statistics type name
origin: String, // url path of spin
sessionId: Number,
time: Number, // time in milliseconds from start of session to current moment
type: String // spin - component type
}

Send this data to your analytics tool to see how visitors use your viewers.

Back to top