Last updated
This browser
DeviceOrientationEvent can report beta, front to back, and gamma, left to right. iPhone Safari only asks after you press Start, and it can still say no. This page shows the latest reading and does not store or send a history.
No sensor on this desktop or tablet? Move the ball with the arrow keys or a drag, or play the simulated example. Those are labeled as such. They are not hardware readings.
Why you'd want to
A ball moves from this device's orientation, or from the keyboard, a drag, or a scripted example. Permission is asked only after Start, and nothing is saved.
How to use it
Not listening. Permission has not been requested.
No reading yet
Arrow keys work after you focus the level. Reduced motion keeps the simulated example still.
Example vendor setup is marked below. eVar and event numbers are examples. This lab does not call Adobe.
The tilt lab moves a ball from a device orientation event, or from the keyboard, a drag, or a scripted example, and it asks for permission only after Start. The lab sends no event of its own, and it does not call Adobe.
Ask only from Start
startSensors calls requestPermission on DeviceOrientationEvent and DeviceMotionEvent when those functions exist. A denial or a throw sets the phase to denied. A missing DeviceOrientationEvent sets unsupported.
Store the latest beta and gamma
The listener ignores events unless the phase is sensor or quiet, and it ignores events with a null beta or gamma. A reading sets the phase to sensor.
Clamp the ball inside the well
Keyboard nudges and the drag pass beta and gamma through clampTilt, which keeps them between -32 and 32 degrees. The simulated path uses cosine and sine, or one fixed pair when reduced motion is on.
Stop without saving
Hiding the page or leaving it removes the listener and the timer. The section is marked data-track-ignore. This file does not call trackLabEvent.
Orientation events become a beta and gamma reading. Null angles are ignored.
function attachSensors() {
removeSensors()
const listener = (event: DeviceOrientationEvent) => {
if (phaseRef.current !== "sensor" && phaseRef.current !== "quiet") return
if (event.beta == null || event.gamma == null) return
setReading({ beta: event.beta, gamma: event.gamma, source: "sensor" })
phaseRef.current = "sensor"
setPhase("sensor")
}
listenerRef.current = listener
window.addEventListener("deviceorientation", listener)Start is what asks for permission. A denial stops before the listener is attached.
async function startSensors() {
haltMotion()
const orientation = DeviceOrientationEvent as typeof DeviceOrientationEvent & { requestPermission?: () => Promise<string> }
const motion = DeviceMotionEvent as typeof DeviceMotionEvent & { requestPermission?: () => Promise<string> }
if (typeof DeviceOrientationEvent === "undefined") {
phaseRef.current = "unsupported"
setPhase("unsupported")
return
}
try {
if (typeof orientation.requestPermission === "function") {
const result = await orientation.requestPermission()
if (result !== "granted") {
phaseRef.current = "denied"
setPhase("denied")
return
}This lab does not queue its own event. The Google block shows an example of how you would track the interaction. Adobe is an example too.
This lab does not queue an analytics event of its own. After Accept, the site still queues virtual_page_view for the page, with page_path and page_title. Clicks inside a data-track-ignore region are not recorded. The push below is an example, not a call this page makes. This site does not call gtag('set') or Adobe.
Example only. This page does not push this object.
// Example only. This lab does not queue this event.
dataLayer.push({
event: "tilt_reading_example",
source: "sensor",
beta: 12,
})Example implementation. This site does not call Adobe. eVar109, prop109, and event109 are example variable numbers. In Launch, a data element reads the value and a rule sends it when the value changes. In the report suite, enable eVar109 with Most Recent allocation and expire it on the hit. A processing rule is unnecessary if the data element maps straight to that eVar.
Example alloy payload. _example is a placeholder schema, not a real tenant.
alloy("sendEvent", {
xdm: {
eventType: "web.webinteraction.linkClicks",
_example: {
tiltSource: "sensor",
},
},
})Example hit. eVar109 is hit-scoped in this example. prop109 dies at the same hit.
s.eVar109 = "sensor"
s.prop109 = "sensor"
s.events = "event109"
s.linkTrackVars = "eVar109,prop109,events"
s.linkTrackEvents = "event109"
s.tl(true, "o", "tilt_reading_example")Each lab field, the GA4 name, and the example Adobe variable. Scope is the part that usually gets lost in the translation.
Reading source
GA4. Not sent. The phase is sensor, keyboard, touch, or simulated.
Adobe. Example eVar109, expire on the hit. Not sent.
Scope. Hit, if you tracked the source. It is not a user property.
Beta and gamma
GA4. Not sent. They stay in component state.
Adobe. Example prop109. Do not put the angle in a prop. Not sent.
Scope. A local reading. It is not an event and not a visit property.
Permission
GA4. Not sent. Denied and unsupported are phases on the page.
Adobe. Example eVar109 for the word denied. Not sent.
Scope. A gate for this hit. It is not a user property.
Simulated example
GA4. Not sent. The timer writes example angles, not a hardware reading.
Adobe. Example prop109. Not sent.
Scope. Local state. It is not an event on the visit.
Scan a QR code in this browser. The camera starts only after a click, nothing is uploaded, and the sample code only says hello. The demo still works.
Set the network's city beside a browser point you choose to share. The map draws the gap and the distance. The point stays in this tab and is not stored.
The signals used to measure a visit can also change the page.