Google Tag Manager
Google Tag Manager (GTM) allows you to add code snippets or tracking pixels to your website with minimal code changes. This makes it an efficient way to integrate Rybbit without modifying your codebase.
How to Add Rybbit to Google Tag Manager
1. Retrieve Your Tracking Script
Navigate to your Rybbit dashboard to obtain your code snippet.
Normally, the script would look like:
<script
src="https://app.rybbit.io/api/script.js"
data-site-id="YOUR_SITE_ID"
async
></script>
However, GTM sanitizes script tags by removing non-standard HTML attributes like data-site-id
. So you need to use:
<script>
(function() {
var el = document.createElement("script");
el.src = "https://app.rybbit.io/api/script.js";
el.async = true;
el.defer = true;
el.setAttribute("data-site-id", "YOUR_SITE_ID");
document.head.appendChild(el);
})();
</script>
2. Access Your GTM Dashboard
Assuming GTM is already set up, go to your GTM dashboard and select the appropriate account and container linked to your website.
3. Create a New Tag
Click on Add a new tag to initiate the creation process.
4. Configure the Tag
Under Tag Configuration, choose Custom HTML and paste your Rybbit snippet into the provided field.
5. Set Up Triggers
Assign a trigger to determine when the tag should fire. For instance, to load Rybbit on all pages, select the All Pages trigger.
6. Save and Publish
Save your changes and publish the container to make the tag active on your website.