All integration guides

Integration guide

Analytics on Webflow

The snippet goes in your site-wide custom code, which Webflow adds to every published page. Forms and buttons become events with a short footer script.

Before you start

  • A paid Webflow plan that allows site-wide custom code.
  • Your site_key, and your published domain under Allowed origins — add your *.webflow.io domain too if you want to measure staging.

Installation

  1. 1Paste the snippet in Head code

    In your site’s settings, open Site settings → Custom code and paste the snippet in Head code. Save.

    Site settings → Custom code → Head code
    <script src="https://cdn.jsdelivr.net/npm/@racoelho/analytics@0.2/dist/index.global.js"></script>
    <script>window.analytics = new Analytics.Analytics({ siteKey: 'YOUR_SITE_KEY' })</script>
  2. 2Publish the site

    Custom code only runs on the published site, not inside the Designer. Click Publish to the domain you registered.

Events and goals

Paste this in Footer code (same screen). It sends a form_submit for every form and an event for every element with a data-track attribute — add the attribute in the Designer under Element settings → Custom attributes.

Site settings → Custom code → Footer code
<script>
  // every Webflow form: the name comes from the data-name attribute
  document.querySelectorAll('form').forEach(function (form) {
    form.addEventListener('submit', function () {
      window.analytics && window.analytics.formSubmit(form.id, form.getAttribute('data-name'))
    })
  })

  // buttons marked with the attribute data-track="event-name"
  document.querySelectorAll('[data-track]').forEach(function (el) {
    el.addEventListener('click', function () {
      window.analytics && window.analytics.track(el.getAttribute('data-track'))
    })
  })
</script>

In the dashboard, create event goals with the same names (form_submit, cta_click…). If the form redirects to a thank-you page, a path goal works too.

Page navigation

Webflow sites reload the page on every link, and each load counts its own pageview. Nothing to configure.

Check that it works

  1. Open the published site in a normal window, with no ad blocker.
  2. In your browser devtools, Network tab, filter by v1/i: you should see a POST with status 200 within 3 seconds (or when you leave the page).
  3. In the dashboard, events show up in about 30 seconds.
  4. After publishing, open the site on the published domain (not in the Designer) and look for the POST.

Troubleshooting

The custom code field is locked
Custom code requires a paid Webflow plan. Without one, the snippet isn’t published.
It works on my domain but not on .webflow.io
Each domain is a different origin. Add both under Allowed origins, or only production if you don’t want test visits mixed in.
The request returns 403 (origin_not_allowed)
Your domain isn’t in Allowed origins in the site settings. Add the exact origin — with https://, with and without www, plus test addresses like http://localhost:3000 if you want to measure in development.
No request shows up in the Network tab
The SDK honors Do Not Track by default: if your browser sends DNT, nothing is sent. Test in another browser or profile. Ad blockers can also block the script.
Pageviews show up twice
The SDK was initialized twice (for example, pasted in the theme and also added by a plugin). Keep a single instance per page.

Create your account and grab the site_key

Free up to 10K events a month, no credit card.

Create a free account
Webflow analytics without cookies: custom code · Analisa