Back to Developer Home

Storepoint Widget JavaScript API

Customize and extend your embedded store locator with our JavaScript API. Listen for events, trigger actions, and create seamless integrations between your application and the Storepoint widget.

Get Started →

Installation

Get Your Embed Code

Find your unique embed code (and public widget ID) on the 'Embed Locator' page in your dashboard.

Get Embed Code

Basic implementation example:

HTML
<!-- Place the widget container wherever you want the store locator to appear -->
<div id="storepoint-widget"></div>

<!-- Place these scripts before the closing body tag -->
<script src="https://widget.storepoint.co/embed.js"></script>
<script>
var storepoint = new StorepointWidget('YOUR_PUBLIC_WIDGET_ID', '#storepoint-widget', {
    // Optional configuration options
});
</script>

Remember to replace 'YOUR_PUBLIC_WIDGET_ID' with your public widget ID, or use the embed code directly from your dashboard embed locator page.

This shows a simplified synchronous loading version. The default embed code from your dashboard uses async loading for better performance. You can implement your own async loading too - just remember to initialize the widget after the embed.js script has loaded.

API Methods

setLanguage(language: ISO2Code)

Sets the locator widget's display language using a two-letter ISO language code (e.g. 'en', 'es', 'fr'). The language must be configured first in your Language Settings.

Only languages that have been configured in your dashboard settings will work. Make sure to set up your desired languages and translations in the Language Settings page before using this method.

JavaScript
// Example: Change to French (if configured in dashboard)
storepoint.setLanguage('fr');  // ISO code for French

// Example: Change to Spanish (if configured in dashboard)
storepoint.setLanguage('es');  // ISO code for Spanish

setFilters(filters: Array<string>)

Programmatically sets active filters on the widget.

JavaScript
storepoint.setFilters(['featured', 'premium']); // Activates these filter tags

on(event: string, callback: Function)

Subscribes to widget events. The callback function receives event-specific data.

JavaScript
storepoint.on('search', function(data) {
    console.log('Search performed:', data);
});

Available Events

Search Events

search

Triggered when a search is performed.

JavaScript
storepoint.on('search', function(data) {
    // data contains:
    // {
    //   lat: number|null,        // Latitude of search point
    //   lng: number|null,        // Longitude of search point
    //   query: string,           // Search text
    //   type: string,            // Search type (e.g., 'initial_search', 'filter_change')
    //   storepoint_location_id: number|null,  // ID of nearest location
    //   distance: number|null,   // Distance to nearest location
    //   tags: string[]|null      // Active filter tags
    // }
});

Location Events

location-result-item-click

Triggered when a location in the results list is clicked.

JavaScript
storepoint.on('location-result-item-click', function(data) {
    // data contains location details
});

map-marker-click

Triggered when a location marker on the map is clicked.

JavaScript
storepoint.on('map-marker-click', function(data) {
    // data contains location details
});

Online Store Events

online-store-click

Triggered when an online store link is clicked.

JavaScript
storepoint.on('online-store-click', function(data) {
    // data contains:
    // {
    //   store_name: string,  // Name of the online store
    //   store_link: string   // URL of the online store
    // }
});

Widget Events

load

Triggered when the widget initially loads.

JavaScript
storepoint.on('load', function(data) {
    // data contains:
    // {
    //   url: string,      // Current page URL
    //   referrer: string  // Referrer URL
    // }
});

no-results

Triggered when a search returns no results.

JavaScript
storepoint.on('no-results', function(data) {
    // Useful for implementing fallback behavior
    window.location.href = '/store-not-found';
});

Interested in other events or functions?

We're constantly expanding our API capabilities. Contact us to discuss your specific needs or request new features.

Contact us at [email protected]