If your template is part of one of the following Squarespace template families, chances are you have Ajax loading enabled.
Ajax is supported by these template families:
Brine
Farro
Skye - Blog landing page only
Tremont
York
If you have Ajax loading enabled on your template, the StoreRocket store locator widget needs a little tweak in order to work properly, because Ajax loading changes the standard behavior of how your website pages are loaded.
Option 1 - Disable Ajax loading
If you don't mind disabling Ajax loading, then you can disable it.
To enable or disable Ajax:
In the Home Menu, click Design, and then click Site Styles.
Scroll down to Site: Loading.
Check or uncheck Enable Ajax Loading.
Done. Now you can install the StoreRocket store locator widget by following the standard Widget Installation instructions.
Option 2 - Keep Ajax loading enabled
If you want to keep Ajax loading enabled, here are the easy and quick instructions to make everything work.
The first step is creating the page that will contain the store locator on your website.
In the Home Menu, click Pages.
Create a new page or choose an existing page from the list.
In the page content, add a new Code content block.
In the Code content block, add the following code:
<div class="storerocket-store-locator"></div>
Great. Now let's add the code to initialize the store locator on every page load.
IMPORTANT NOTE: The Code Injection feature is a Squarespace Premium feature and is only available in the SquareSpace Business and Commercial plans.
In the Home Menu, click Settings, and then click Advanced.
Now click Code Injection.
In the Header section, add this code:
<script src="//cdn.storerocket.io/widget.js"></script>
<script>
document.addEventListener('DOMContentLoaded', initStoreRocket);
window.addEventListener('mercury:load', initStoreRocket);
function initStoreRocket() {
var config = {
selector: ".storerocket-store-locator",
account: "YOUR_ACCOUNT_ID", // CHANGE THIS
};
if (document.querySelector(config.selector)) {
StoreRocket.init(config);
}
}
</script>
In the code, change YOUR_ACCOUNT_ID
with your account ID that you find in your account page — please don't remove the double quotes that wrap your account ID (example "asdfg1234"
).
Save everything and you should be good to go. The store locator should now load properly on every Ajax page load.
Congratulations! 👏🏻🥂