Stickybeak Docs Dashboard Get early access

Backends

Wagtail

Wagtail analytics with Stickybeak starts by adding its script to your rendered pages; this guide shows you where it belongs and how to track page views, goals and purchase revenue.

Add the script

Follow the Django guide to add the setting, the context processor and the tag.

<script>window.stickybeak = window.stickybeak || function () { (window.stickybeak.q = window.stickybeak.q || []).push(arguments); };</script>
{% if STICKYBEAK_SITE_ID %}
  <script
    defer
    data-site="{{ STICKYBEAK_SITE_ID }}"
    data-domain="example.com"
    src="https://app.usestickybeak.com/_cfw/s.js"
  ></script>
{% endif %}
Editors and previews

The Wagtail admin doesn't use your base template, so editors aren't counted while they work. Previews load in an iframe, which Stickybeak doesn't count either.

Check it's working

Publish first, then follow Verify your install.

Track goals

When someone submits a form page, Wagtail renders its landing template in place of the form.

{% extends "base.html" %}

{% block content %}
  <h1>Thanks!</h1>
  {{ page.thank_you_text|richtext }}
{% endblock %}

{% block extra_js %}
  <script>window.stickybeak("contact_form", { form: "{{ page.slug|escapejs }}" });</script>
{% endblock %}

escapejs makes the slug safe inside a JavaScript string.

The landing page is the response to the form post, so the address doesn't change and no redirect is involved.

Other goals

  • For clicks, add data-goal to buttons and links in your templates.
  • For things your own views save and redirect after, use the session pattern in the Django guide.

See Custom goals.

Track purchases

Render window.stickybeak("purchase", { revenue, currency, order_id }) on the checkout confirmation page.

See Revenue.

If it isn't working

  • The admin and iframe previews are not counted. Put form goals in the landing template.

See Troubleshooting.