Install on your platform
Where to paste the snippet on Webflow, WordPress, Tag Manager, Shopify, Squarespace, Wix, Next.js and bundled apps.
There are three ways to install, and the key travels differently in each: on the script tag for a site whose head you can edit, on window.localWrangler for Google Tag Manager, and in your own code for a bundled app. Each section below shows the snippet for its platform. Copy the live version from Tracking, then Tracking Script so the key is yours, then follow your platform.
Generic HTML site
For any hand-built or static HTML site, paste the snippet directly into the page head.
- 1Open your site template or each HTML file and find the closing
</head>tag. - 2Paste the snippet just before it.
- 3Deploy and verify a pageview appears in Analytics.
<script src="https://localwrangler.com/track.js" data-key="lw_xxxxxxxx" async></script>Webflow
Webflow lets you add custom code to the site head without touching individual pages.
- 1In the Webflow Designer, open Site settings, Custom code.
- 2Paste the snippet into the Head code field.
- 3Save, then publish your site.
<script src="https://localwrangler.com/track.js" data-key="lw_xxxxxxxx" async></script>WordPress
On WordPress, the cleanest path is a header-injection plugin so updates to your theme do not wipe the snippet.
- 1Install a header snippet plugin such as WPCode or Insert Headers and Footers.
- 2Open its settings and find the Header section.
- 3Paste the snippet and save.
<script src="https://localwrangler.com/track.js" data-key="lw_xxxxxxxx" async></script>Google Tag Manager
If you manage tags through Google Tag Manager, add the tracker as a Custom HTML tag. Tag Manager injects the tag itself, so the key is set on the page instead of on the script tag.
- 1In Tag Manager, create a new tag of type Custom HTML.
- 2Paste the code below into the HTML field.
- 3Set the trigger to All Pages, then save and publish the container.
<script>
window.localWrangler = { key: "lw_xxxxxxxx" };
</script>
<script src="https://localwrangler.com/track.js" async></script>Shopify
Shopify themes expose the layout file where the head is defined.
- 1From your admin, open Online Store, Themes.
- 2Click the three dots on your live theme and choose Edit code.
- 3Open
layout/theme.liquidand paste the snippet just before the closing head tag.
<script src="https://localwrangler.com/track.js" data-key="lw_xxxxxxxx" async></script>Squarespace
Squarespace has a built-in code injection panel for the site head.
- 1Open Settings, Advanced, Code Injection.
- 2Paste the snippet into the Header field.
- 3Save.
<script src="https://localwrangler.com/track.js" data-key="lw_xxxxxxxx" async></script>Wix
Wix supports custom code through its settings, applied to all pages.
- 1Open Settings, then Custom code under Advanced.
- 2Add a new code snippet and paste it in.
- 3Set it to load on All pages, in the Head, then apply.
<script src="https://localwrangler.com/track.js" data-key="lw_xxxxxxxx" async></script>Next.js
In Next.js the root layout renders on the server, so the tracker is loaded through the framework's Script component, which runs the code in the browser once the page is interactive.
- 1In
app/layout.tsx, importScriptfromnext/script. - 2Add the block below to your root layout. The
idis required for an inline script, andafterInteractiveruns it client-side after hydration. - 3Rebuild, open your site, and verify a pageview appears in Analytics.
import Script from "next/script";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
<Script id="local-wrangler" strategy="afterInteractive">{`
// Run this once in the browser, before the tracker loads.
window.localWrangler = { key: "lw_xxxxxxxx" };
const s = document.createElement("script");
s.src = "https://localwrangler.com/track.js";
s.async = true;
document.head.appendChild(s);
`}</Script>
</html>
);
}JavaScript app (React, Vue and other bundled apps)
For an app bundled for the browser where there is no static head to edit, load the tracker once at startup.
- 1Copy the code below.
- 2Run it once when your app starts, in code that runs in the browser, such as your app's entry file. If your framework renders on the server, use its client-side script component instead, as in the Next.js section above.
- 3Rebuild, open your site, and verify a pageview appears in Analytics.
// Run this once in the browser, before the tracker loads.
window.localWrangler = { key: "lw_xxxxxxxx" };
const s = document.createElement("script");
s.src = "https://localwrangler.com/track.js";
s.async = true;
document.head.appendChild(s);