Skip to content

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

Add WordPress integration (#223)

Edward Cuibcc845f010c6
diff --git a/docs/src/content/integrations/next-js.mdx b/docs/src/content/integrations/next-js.mdx
index 7974a6409..b8c2deb0c 100644
--- a/docs/src/content/integrations/next-js.mdx
+++ b/docs/src/content/integrations/next-js.mdx
@@ -1,4 +1,3 @@
-
# Next.js
Next.js is a popular React framework that enables features like server-side rendering and static site generation. This guide explains how to integrate Rybbit with your Next.js application.
@@ -13,7 +12,7 @@ Create or modify your layout file (either `app/layout.js` or `pages/_app.js` dep
```jsx
// For App Router (Next.js 13+)
-import Script from 'next/script'
+import Script from "next/script"
export default function RootLayout({ children }) {
return (
@@ -34,7 +33,7 @@ export default function RootLayout({ children }) {
```jsx
// For Pages Router
-import Script from 'next/script'
+import Script from "next/script"
function MyApp({ Component, pageProps }) {
return (
@@ -51,4 +50,3 @@ function MyApp({ Component, pageProps }) {
export default MyApp
```
-
diff --git a/docs/src/content/integrations/wordpress.mdx b/docs/src/content/integrations/wordpress.mdx
new file mode 100644
index 000000000..9d0a17629
--- /dev/null
+++ b/docs/src/content/integrations/wordpress.mdx
@@ -0,0 +1,43 @@
+# WordPress
+
+You can integrate Rybbit into your WordPress site to track user behavior and gather analytics. There are several ways to do this depending on whether you're using a hosted WordPress.com site or a self-hosted WordPress.org installation.
+
+## Option 1: Use a Plugin
+
+If you don't want to modify your theme files directly, you can use a plugin to inject the Rybbit snippet. This is the only option for WordPress.com users.
+
+1. Install the [Insert Headers and Footers](https://wordpress.com/plugins/insert-headers-and-footers) plugin.
+2. Go to the plugin settings and paste your snippet into the `<header>` section.
+3. Save your changes.
+
+## Option 2: Add to `functions.php`
+
+If you're using a self-hosted WordPress theme, you can add the script via `functions.php`.
+
+1. In your WordPress dashboard, go to **Tools > Theme File Editor**.
+2. Open the `functions.php` file.
+3. Add the following code:
+
+```php
+function add_rybbit() {
+ ?>
+ <script
+ src="https://app.rybbit.io/api/script.js"
+ data-site-id="YOUR_SITE_ID"
+ async
+ ></script>
+ <?php
+}
+add_action("wp_head", "add_rybbit");
+```
+
+4. Save the file.
+
+## Option 3: Modify `header.php`
+
+You can also manually add the script to your theme's HTML header if using an older version of WordPress.
+
+1. Go to **Appearance > Theme Editor**.
+2. Open the `header.php` file.
+3. Paste your snippet right before the closing `</head>` tag.
+4. Save the file.