Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Update Drupal docs to reference contributed rybbit module (#984)

Allie Mickaff59ae768de1
diff --git a/docs/content/docs/guides/drupal.mdx b/docs/content/docs/guides/drupal.mdx
index 205b9ffbf..abd9a9e4c 100644
--- a/docs/content/docs/guides/drupal.mdx
+++ b/docs/content/docs/guides/drupal.mdx
@@ -1,15 +1,20 @@
---
title: Drupal
-description: Integrate Rybbit Analytics with your Drupal site using theme files or modules
+description: Integrate Rybbit Analytics with your Drupal site using the rybbit module
---
import { Steps, Step } from 'fumadocs-ui/components/steps';
import { Callout } from 'fumadocs-ui/components/callout';
-Integrating Rybbit Analytics with your Drupal site can be done by adding the tracking script to your theme or by using a module that allows adding custom JavaScript.
+Drupal is a flexible and secure content management system that features robust content modeling and user management tools. You can add Rybbit to Drupal to track anonymous and logged-in users.
+
+## How to Add Rybbit to Drupal
+
+You can add Rybbit to your site by installing the [Rybbit](https://drupal.org/project/rybbit) module from Drupal.org
<Steps>
<Step>
+
### Get Your Tracking Script
First, you'll need your Rybbit tracking script. You can find this in your Rybbit dashboard under **Site Settings > Tracking Code**. It will look something like this:
@@ -20,92 +25,23 @@ First, you'll need your Rybbit tracking script. You can find this in your Rybbit
Replace `YOUR_SITE_ID` with your actual Site ID from your Rybbit dashboard.
</Step>
-</Steps>
-
-## Method 1: Adding to Your Theme (Recommended for Themers)
-
-If you are comfortable editing your Drupal theme files, this is a direct way to add the script.
-
-<Steps>
-<Step>
-### Locate your theme's `html.html.twig` file
-
-This file is responsible for the overall HTML structure of your pages. You can typically find it in your active theme's directory:
-`themes/custom/your_theme_name/templates/layout/html.html.twig`
-
-If your custom theme doesn't have one, you might need to copy it from your base theme (e.g., Stable, Classy) or from Drupal core (`core/themes/stable/templates/layout/html.html.twig`).
-</Step>
-
<Step>
-### Add the script
-Open the `html.html.twig` file and paste the Rybbit tracking script just before the closing `</body>` tag.
+### Download and install the Rybbit module
-```twig
-{# ... existing content ... #}
- <js-bottom-placeholder token="{{ placeholder_token }}">
- </body>
-</html>
+Follow Drupal's [recommended procedure](https://www.drupal.org/docs/extending-drupal/installing-modules) for installing the Rybbit module from https://www.drupal.org/project/rybbit:
```
-
-Modify it to include the script:
-
-```twig
-{# ... existing content ... #}
- <js-bottom-placeholder token="{{ placeholder_token }}">
-
- {# Rybbit Analytics Script #}
- <script async defer src="https://app.rybbit.io/api/script.js" data-site-id="YOUR_SITE_ID"></script>
- </body>
-</html>
+ $ composer require drupal/rybbit
+ $ drush en rybbit
```
-Replace `YOUR_SITE_ID` with your actual Site ID.
</Step>
-
-<Step>
-### Clear Drupal Caches
-
-After adding the script, you must clear Drupal's caches for the changes to take effect.
-- Go to **Manage > Configuration > Development > Performance** (e.g., `/admin/config/development/performance`).
-- Click the **Clear all caches** button.
-- Alternatively, use Drush: `drush cr`
-</Step>
-</Steps>
-
-<Callout type="warn">
- Be cautious when adding scripts directly to `html.html.twig` if you are not using a custom theme, as core or contrib theme updates might overwrite your changes. Creating a sub-theme is best practice.
-</Callout>
-
-## Method 2: Using a Module (e.g., "Asset Injector")
-
-For users less comfortable with code, or for more flexible management, a module like [Asset Injector](https://www.drupal.org/project/asset_injector) can be used.
-
-<Steps>
<Step>
-### Install and Enable Asset Injector
-
-- Download and install the Asset Injector module from Drupal.org.
-- Enable the module via **Manage > Extend** (`/admin/modules`).
-</Step>
-<Step>
-### Add a JavaScript Asset
-
-- Go to **Manage > Configuration > Development > Asset Injector** (`/admin/config/development/asset-injector`).
-- Click on **JS injector**.
-- Click **+ Add JS inject**.
-- **Label:** Give it a name like "Rybbit Analytics".
-- **Code:** Paste your Rybbit tracking script into the code field.
-- **Pages:** Configure where the script should appear. For sitewide tracking, you might select "Add on every page except the listed pages" and leave the list empty, or use specific conditions if needed.
-- **Preprocess JavaScript:** Usually, you can leave this unchecked for external scripts.
-- **Scope:** Select **Footer** to add the script to the bottom of the page.
-</Step>
+### Configure module settings
-<Step>
-### Save and Clear Caches
+Visit `admin/services/rybbit` and add your Site ID to the site's configuration page.
-- Save the asset.
-- Clear Drupal's caches as described in Method 1.
+You can also modify the script's source and loading optimizations, set rules for when the script gets loaded, and configure the site to use the `identify()` method to pass details about logged-in users from Drupal to Rybbit.
</Step>
</Steps>
@@ -113,6 +49,7 @@ For users less comfortable with code, or for more flexible management, a module
<Steps>
<Step>
+
### Test Your Integration
- Open your live Drupal website in a browser.
@@ -121,4 +58,4 @@ For users less comfortable with code, or for more flexible management, a module
</Step>
</Steps>
-That's it! Rybbit Analytics should now be integrated with your Drupal site.
\ No newline at end of file
+That's it! Rybbit Analytics should now be integrated with your Drupal site.