Developer Portal
Widget customization

Receiving events

Listen for postMessage events from the Spin Widget iframe.

The Spin Widget runs inside an iframe and posts messages to the parent window when the user interacts with it. The widget is served from spins.impel.ai. The legacy aliases spins.impel.io and spins.spincar.com may also be in use, so host pages should accept all three as valid origins.

Each Impel message is a string with a known prefix:

PrefixFormat
sts-post-analytics:Prefix + JSON body, for example sts-post-analytics:{"event":"view_360_popout"}
STS:FullBrowser::Prefix + string data (open or close)

Quickstart listener

window.addEventListener('message', (event) => {
  if (!/^https:\/\/spins\.(impel\.ai|impel\.io|spincar\.com)$/.test(event.origin)) return;
  if (typeof event.data !== 'string') return;

  const ANALYTICS_PREFIX = 'sts-post-analytics:';
  if (event.data.indexOf(ANALYTICS_PREFIX) === 0) {
    const message = JSON.parse(event.data.substring(ANALYTICS_PREFIX.length));
    handleAnalyticsEvent(message.event, message.data);
    return;
  }

  const FULLSCREEN_PREFIX = 'STS:FullBrowser::';
  if (event.data.indexOf(FULLSCREEN_PREFIX) === 0) {
    const action = event.data.substring(FULLSCREEN_PREFIX.length); // 'open' or 'close'
    handleFullScreen(action);
    return;
  }
});

Post analytics

Enable post-analytics to track user engagement with the widget (clicks, view changes, photo navigation) in your own analytics platform alongside your other site events.

Enable it by setting !postanalytics=<URL> in the URL fragment, where <URL> is the origin of the host page, for example https://www.exampledealer.com. The widget passes this URL as the targetOrigin argument to postMessage, so messages are delivered only to a parent at that origin.

EventTriggerdata
view_360_popoutUser clicks "View Full Screen"—
view_hotspotsUser toggles hotspots on—
hide_hotspotsUser toggles hotspots off—
view_interiorUser switches to the interior view from the toggle—
view_exteriorUser switches to the exterior view from the toggle—
click_360_exteriorUser clicks or interacts with the exterior 360 spin—
click_360_interiorUser clicks or interacts with the interior 360 spin—
click_photo_thumbnailUser clicks a photo thumbnail from the carousel—
view_photoUser views a photo in the Photo Viewer{name}
click_carousel_navigation_leftUser clicks the carousel's left arrow—
click_carousel_navigation_rightUser clicks the carousel's right arrow—
click_photoviewer_navigation_leftUser clicks the Photo Viewer's left arrow—
click_photoviewer_navigation_rightUser clicks the Photo Viewer's right arrow—
click_close_photoviewerUser closes the Photo Viewer—

Full screen

Enable full-screen messaging to let users expand the widget within their browser. The host page resizes the iframe in response to the messages.

Enable it by setting !enableWideScreenView (see Display and behavior).

Widget with the full-screen toggle button highlighted in the top-right corner
DataMeaning
openUser requested an expanded view
closeUser requested to return to the normal view

On this page