Tracking Script
To start tracking user activity on your website, add the Rybbit tracking script to your site’s HTML.
Installation
The webpage should give you this script tag like this when you first add a website. Place it within the <head>
section of your website. Include it on every page you wish to track.
<script src="https://app.rybbit.io/api/script.js" async data-site-id="YOUR_SITE_ID"></script>
If you are self-hosting Rybbit app.rybbit.io
will be domain of your Rybbit instance.
Configuration Options
You can customize the script’s behavior using data-*
attributes on the <script>
tag:
Attribute | Type | Default | Description |
---|---|---|---|
data-track-spa | string | "true" | Set to "false" to disable automatic pageview tracking for single page applications (React, Vue, etc). You will need to manually call window.rybbit.pageview() or window.rybbit.track() for all but the initial pageview. |
data-track-query | string | "true" | Set to "false" to disable tracking of URL query strings. This enhances privacy by preventing potentially sensitive information in query parameters from being stored in your analytics data. |
data-skip-patterns | string | [] | A JSON string array of URL path patterns to ignore. Pageviews matching these patterns won’t be tracked. Supports two types of wildcards: * (matches within a segment) and ** (matches across segments). |
data-mask-patterns | string | [] | A JSON string array of URL path patterns to mask for privacy. Pageviews matching these patterns will be tracked, but the actual URL path will be replaced with the pattern itself in analytics data. Supports the same wildcards as data-skip-patterns . |
data-debounce | string | "500" | The delay (in milliseconds) before tracking a pageview after URL changes via the History API (pushState , replaceState ). Set to 0 to disable debouncing. |
Pattern Matching Details
For data-skip-patterns
and data-mask-patterns
, two types of wildcards are supported:
*
- Matches any characters within a single path segment (doesn’t match across/
)**
- Matches any characters across multiple path segments (includes/
)
Examples:
/admin/*
matches/admin/dashboard
but not/admin/users/list
/admin/**
matches both/admin/dashboard
and/admin/users/list
/blog/*/comments
matches/blog/post-123/comments
but not/blog/category/post/comments
Example usage:
data-skip-patterns='["/admin/**", "/blog/drafts/*", "/preview/**"]'
data-mask-patterns='["/users/*/settings", "/accounts/**", "/orders/*/details"]'
Example with multiple options:
<script
src="https://api.rybbit.io/api/script.js"
async
data-site-id="456"
data-skip-patterns='["/admin/**", "/preview/*"]'
data-mask-patterns='["/users/*/profile", "/orders/**"]'
data-track-query="false"
data-debounce="300"
></script>
Last updated on