Connect Your Squarespace Store
Follow these steps to connect your Squarespace store to VYA. No coding knowledge needed — just copy, paste, and save.
This takes about 5 minutes. You'll just be copying and pasting one block of text into your Squarespace settings.
Before You Start
You'll need access to your Squarespace website settings. Make sure you're logged in as an admin on your Squarespace site.
Note: This requires a Squarespace Business plan or higher. If you're on a Personal plan, you'll need to upgrade first.
Enter Your Store Name
Type in your store details below. The code in Step 2 will update automatically with your info.
Copy & Paste the Code
Fill in your store name and store ID in Step 1 first — the code will automatically include your store info.
Here's what to do:
- a.In your Squarespace admin, go to Settings → Advanced → Code Injection
- b.Find the box labeled Header
- c.Click Copy below and paste it into that box
<!-- VYA Tracking -->
<script>
(function() {
// Save via_click_id from URL into a 30-day cookie
var urlParams = new URLSearchParams(window.location.search);
var clickId = urlParams.get('via_click_id');
if (clickId) {
document.cookie = 'via_click_id=' + clickId + ';max-age=2592000;path=/;SameSite=Lax';
}
// Fire conversion when customer lands on order confirmation page
if (window.location.pathname.indexOf('/commerce/orders/') === -1) return;
var pathParts = window.location.pathname.split('/');
var orderId = pathParts[pathParts.length - 1];
if (!orderId || orderId.length < 10) return;
// Prevent double-firing
if (sessionStorage.getItem('via_' + orderId)) return;
sessionStorage.setItem('via_' + orderId, '1');
// Read via_click_id from cookie
var viaClickId = null;
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var c = cookies[i].trim();
if (c.indexOf('via_click_id=') === 0) { viaClickId = c.substring(13); break; }
}
// Find the order total — take the largest dollar amount on the page
function findTotal() {
var matches = document.body.innerText.match(/\$[\d,]+\.\d{2}/g) || [];
var amounts = matches.map(function(m) { return parseFloat(m.replace(/[\$,]/g, '')); });
return amounts.length ? Math.max.apply(null, amounts) : 0;
}
function send() {
fetch('https://vyaplatform.com/api/conversion', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
orderId: orderId,
orderTotal: findTotal(),
currency: 'USD',
items: [],
viaClickId: viaClickId,
storeSlug: 'your-store-slug',
storeName: 'Your Store Name'
})
}).catch(function() {});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', send);
} else {
send();
}
})();
</script>If you previously installed two VYA code blocks, replace your existing Header code with this one and delete the Order Confirmation code — this single block handles everything.
Hit Save
Click the Save button at the top of the Squarespace Code Injection page. That's it — you're all set!
Once saved, VYA will automatically know when a customer we send to your store makes a purchase. You don't need to do anything else.
Questions
Will this affect my website speed or checkout?
No. It's a tiny piece of code that runs in the background. Your customers won't notice anything different.
Does this track all my customers?
No — only customers who came from VYA. If someone finds your store on their own, nothing happens. We never collect customer names, emails, or personal info.
What if a customer browses other products after clicking from VYA?
If a customer clicks through from VYA and ends up buying a different item on your store, VYA still gets credit. The tracking lasts for 30 days from their first click.
Can I remove this later?
Yes. Just go back to Code Injection and delete the code from the Header box. No changes to your site will remain.
Stuck or have questions? Email us at partnerships@theviaplatform.com and we'll walk you through it.
