PART 3 — JAVASCRIPT
Paste into: Squarespace > Settings > Advanced >
Code Injection > Footer
Wrapped in a named function and fired on BOTH:
• DOMContentLoaded — catches hard refreshes / direct URL loads
• mercury:load — catches Squarespace's internal AJAX
navigation (when a visitor clicks a
link and Squarespace swaps the page
content without a full browser reload)
The function safely exits if the destinations page elements
are not present, so it won't error on other pages.
============================================================ -->