Skip to content

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

Update meta.json to simplify framework entries and adjust PricingSection for annual pricing display

Bill Yang6d497a89c8eb
diff --git a/docs-v2/content/docs/guides/meta.json b/docs-v2/content/docs/guides/meta.json
index b9eb88ef4..ad659a673 100644
--- a/docs-v2/content/docs/guides/meta.json
+++ b/docs-v2/content/docs/guides/meta.json
@@ -11,16 +11,11 @@
"hugo",
"jekyll",
"laravel",
- "react/vite-cra",
- "react/next-js",
- "react/gatsby",
- "react/remix",
+ "react",
"shopify",
"squarespace",
- "svelte/vite",
- "svelte/sveltekit",
- "vue/vite",
- "vue/nuxt",
+ "svelte",
+ "vue",
"webflow",
"wix",
"woocommerce",
diff --git a/docs-v2/content/docs/guides/woocommerce.mdx b/docs-v2/content/docs/guides/woocommerce.mdx
new file mode 100644
index 000000000..dc7138be8
--- /dev/null
+++ b/docs-v2/content/docs/guides/woocommerce.mdx
@@ -0,0 +1,220 @@
+---
+title: WooCommerce
+description: Integrate Rybbit Analytics with your WooCommerce store
+---
+
+import { Steps, Step } from 'fumadocs-ui/components/steps';
+import { Callout } from 'fumadocs-ui/components/callout';
+
+
+This guide explains how to integrate Rybbit with your WooCommerce store (running on WordPress) to track e-commerce events like product views, add to carts, and purchases, in addition to standard page view analytics.
+
+## Prerequisites
+
+1. **Rybbit Installed on WordPress**: Ensure you have already installed the Rybbit tracking script on your WordPress site using one of the methods described in our [WordPress integration guide](./wordpress). This guide focuses on adding e-commerce event tracking.
+2. **Access to `functions.php` or Custom Plugin**: You'll need to add PHP snippets. The recommended way is via your child theme's `functions.php` file or a custom plugin to avoid changes being overwritten by theme updates.
+
+## Tracking E-commerce Events
+
+WooCommerce provides various action hooks that allow you to trigger JavaScript when specific e-commerce events occur. We'll use these to send data to Rybbit.
+
+<Callout type="warning">
+ The following PHP code snippets should be added to your **child theme's `functions.php` file** or a **custom site-specific plugin**. Modifying your parent theme's `functions.php` directly is not recommended as changes will be lost upon theme updates.
+</Callout>
+
+### 1. View Product (`view_item`)
+
+Track when a user views a single product page.
+
+```php
+// Add to your child theme's functions.php or a custom plugin
+add_action( 'woocommerce_after_single_product_summary', 'rybbit_track_view_product', 10 );
+function rybbit_track_view_product() {
+ if ( ! is_product() ) { // Ensure it's a single product page
+ return;
+ }
+
+ global $product;
+ if ( ! $product instanceof WC_Product ) {
+ return;
+ }
+
+ $product_data = array(
+ 'item_id' => $product->get_sku() ? $product->get_sku() : $product->get_id(),
+ 'item_name' => $product->get_name(),
+ 'price' => (float) $product->get_price(),
+ 'currency' => get_woocommerce_currency(),
+ );
+ ?>
+ <script type="text/javascript">
+ if (typeof window.rybbit !== 'undefined') {
+ window.rybbit.event('view_item', <?php echo json_encode($product_data); ?>);
+ }
+ </script>
+ <?php
+}
+```
+
+### 2. Add to Cart (`add_to_cart`)
+
+Track when a user adds a product to their cart. This example uses a JavaScript approach triggered after the "Add to Cart" button on single product pages. For AJAX add-to-carts (e.g., on archive pages), a JavaScript event listener on `$(document.body).on('added_to_cart', ...)` might be more robust.
+
+```php
+// Add to your child theme's functions.php or a custom plugin
+add_action( 'woocommerce_after_add_to_cart_button', 'rybbit_track_add_to_cart_script' );
+function rybbit_track_add_to_cart_script() {
+ global $product;
+ if ( ! $product instanceof WC_Product ) {
+ return;
+ }
+
+ $product_data = array(
+ 'item_id' => $product->get_sku() ? $product->get_sku() : $product->get_id(),
+ 'item_name' => $product->get_name(),
+ 'price' => (float) $product->get_price(),
+ 'currency' => get_woocommerce_currency(),
+ // Quantity is typically 1 here, but can be dynamic if your theme supports it before this hook
+ );
+ ?>
+ <script type="text/javascript">
+ document.addEventListener('DOMContentLoaded', function() {
+ const form = document.querySelector('form.cart');
+ if (form) {
+ form.addEventListener('submit', function() {
+ // Attempt to get quantity, default to 1
+ let quantity = 1;
+ const quantityInput = form.querySelector('input.qty');
+ if (quantityInput && quantityInput.value) {
+ quantity = parseInt(quantityInput.value, 10);
+ }
+
+ if (typeof window.rybbit !== 'undefined') {
+ const eventData = <?php echo json_encode($product_data); ?>;
+ eventData.quantity = quantity > 0 ? quantity : 1;
+ window.rybbit.event('add_to_cart', eventData);
+ }
+ });
+ }
+ });
+ </script>
+ <?php
+}
+
+// For AJAX add to cart events (e.g., on shop/category pages)
+add_action( 'wp_footer', 'rybbit_ajax_add_to_cart_tracker' );
+function rybbit_ajax_add_to_cart_tracker() {
+ if ( is_admin() ) return;
+ ?>
+ <script type="text/javascript">
+ jQuery(document.body).on('added_to_cart', function(event, fragments, cart_hash, $button) {
+ if (typeof window.rybbit !== 'undefined' && $button && $button.length) {
+ const productId = $button.data('product_id');
+ const quantity = $button.data('quantity') || 1; // Or $button.closest('.product').find('input.qty').val()
+ // Note: Getting full product details here via AJAX might be needed for price, name, SKU
+ // This example sends basic info. For more details, you might need another AJAX call or pass data via $button.data attributes
+ window.rybbit.event('add_to_cart', {
+ item_id: productId,
+ quantity: quantity,
+ source: 'ajax_add_to_cart'
+ // Consider adding more product details if readily available or via a separate AJAX call
+ });
+ }
+ });
+ </script>
+ <?php
+}
+```
+
+### 3. Begin Checkout (`begin_checkout`)
+
+Track when a user proceeds to the checkout page.
+
+```php
+// Add to your child theme's functions.php or a custom plugin
+add_action( 'woocommerce_before_checkout_form', 'rybbit_track_begin_checkout', 5 );
+function rybbit_track_begin_checkout() {
+ if ( is_admin() || ! is_checkout() ) return;
+
+ $cart = WC()->cart;
+ if ( ! $cart ) return;
+
+ $items = [];
+ foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
+ $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
+ $items[] = array(
+ 'item_id' => $_product->get_sku() ? $_product->get_sku() : $_product->get_id(),
+ 'item_name' => $_product->get_name(),
+ 'price' => (float) $_product->get_price(),
+ 'quantity' => (int) $cart_item['quantity'],
+ );
+ }
+
+ $checkout_data = array(
+ 'currency' => get_woocommerce_currency(),
+ 'value' => (float) $cart->get_total( 'edit' ), // Get total without formatting
+ 'items' => $items,
+ );
+ ?>
+ <script type="text/javascript">
+ if (typeof window.rybbit !== 'undefined') {
+ window.rybbit.event('begin_checkout', <?php echo json_encode($checkout_data); ?>);
+ }
+ </script>
+ <?php
+}
+```
+
+### 4. Purchase (`purchase`)
+
+Track when a purchase is completed (on the "Thank You" page).
+
+```php
+// Add to your child theme's functions.php or a custom plugin
+add_action( 'woocommerce_thankyou', 'rybbit_track_purchase', 10, 1 );
+function rybbit_track_purchase( $order_id ) {
+ if ( ! $order_id ) {
+ return;
+ }
+ $order = wc_get_order( $order_id );
+ if ( ! $order ) {
+ return;
+ }
+
+ $items = [];
+ foreach ( $order->get_items() as $item_id => $item ) {
+ $product = $item->get_product();
+ $items[] = array(
+ 'item_id' => $product ? ($product->get_sku() ? $product->get_sku() : $product->get_id()) : $item->get_product_id(),
+ 'item_name' => $item->get_name(),
+ 'price' => (float) $order->get_line_subtotal( $item, false, false ), // Price for the line item
+ 'quantity' => (int) $item->get_quantity(),
+ );
+ }
+
+ $purchase_data = array(
+ 'transaction_id' => $order->get_order_number(),
+ 'value' => (float) $order->get_total(),
+ 'tax' => (float) $order->get_total_tax(),
+ 'shipping' => (float) $order->get_shipping_total(),
+ 'currency' => $order->get_currency(),
+ 'items' => $items,
+ );
+ ?>
+ <script type="text/javascript">
+ if (typeof window.rybbit !== 'undefined') {
+ window.rybbit.event('purchase', <?php echo json_encode($purchase_data); ?>);
+ }
+ </script>
+ <?php
+}
+```
+
+## Important Considerations
+
+* **Script Loading Order**: Ensure the main Rybbit tracking script (added via the WordPress integration guide) is loaded before these event-specific scripts attempt to call `window.rybbit`. Placing the main script in the `<head>` usually ensures this.
+* **Data Accuracy**: The product data (SKU, name, price) retrieved in these examples depends on your WooCommerce setup and product configuration. Test thoroughly.
+* **AJAX Operations**: For themes or plugins that use AJAX heavily (e.g., AJAX add to cart, mini-cart updates), you might need more sophisticated JavaScript event listeners rather than relying solely on PHP action hooks that fire on page load. The AJAX add-to-cart example provides a starting point.
+* **Performance**: While these snippets are generally lightweight, outputting many inline scripts can have a minor impact. For very high-traffic sites, consider consolidating JavaScript or using more advanced techniques if performance becomes a concern.
+* **Plugin Conflicts**: Test for conflicts if you are using other analytics or tracking plugins.
+
+By implementing these tracking snippets, you can gain valuable insights into your WooCommerce store's performance using Rybbit.
\ No newline at end of file
diff --git a/docs-v2/content/docs/guides/wordpress.mdx b/docs-v2/content/docs/guides/wordpress.mdx
new file mode 100644
index 000000000..819bfa228
--- /dev/null
+++ b/docs-v2/content/docs/guides/wordpress.mdx
@@ -0,0 +1,78 @@
+---
+title: WordPress
+description: Integrate Rybbit Analytics with your WordPress site
+---
+
+import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
+import { Steps, Step } from 'fumadocs-ui/components/steps';
+
+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.
+
+<Tabs items={['Rybbit Plugin', 'Insert Headers & Footers Plugin', 'Add to functions.php', 'Modify header.php']}>
+ <Tab>
+ **Rybbit WordPress Plugin (Recommended for ease of use)**
+
+ You can find our community-maintained WordPress plugin as well as installation instructions [here](https://github.com/didyouexpectthat/rybbit-analytics-tracking-code). This is often the simplest method for most users.
+ </Tab>
+ <Tab>
+ **Insert Headers and Footers Plugin (Good for WordPress.com or no-code approach)**
+
+ If you don't want to modify your theme files directly, or if you are using WordPress.com (where direct theme editing is restricted), you can use a plugin to inject the Rybbit snippet.
+
+ 1. Install the [Insert Headers and Footers](https://wordpress.com/plugins/insert-headers-and-footers) plugin (or a similar plugin that allows adding scripts to the header).
+ 2. Go to the plugin settings (often found under **Settings > Insert Headers and Footers**).
+ 3. Paste your Rybbit tracking snippet into the section designated for scripts in the header.
+ ```html
+ <script
+ src="https://app.rybbit.io/api/script.js"
+ data-site-id="YOUR_SITE_ID"
+ async
+ defer
+ ></script>
+ ```
+ 4. Save your changes.
+ </Tab>
+ <Tab>
+ **Add to `functions.php` (For self-hosted WordPress with child theme)**
+
+ If you're using a self-hosted WordPress theme, you can add the script via `functions.php`. It is **strongly recommended to make these changes in a child theme**. If you modify the parent theme files directly, your changes may be lost when the theme is updated.
+
+ 1. In your WordPress dashboard, go to **Appearance > Theme File Editor**. (Alternatively, edit the file via FTP/SFTP or your hosting file manager, which is safer if you are unfamiliar with editing theme files directly).
+ 2. Open your child theme's `functions.php` file (or your parent theme's `functions.php` if you are not using a child theme, with the above caution in mind).
+ 3. Add the following code to the end of the file:
+ ```php
+ function add_rybbit_script_to_head() {
+ ?>
+ <script
+ src="https://app.rybbit.io/api/script.js"
+ data-site-id="YOUR_SITE_ID" // Replace YOUR_SITE_ID with your actual Site ID
+ async
+ defer
+ ></script>
+ <?php
+ }
+ add_action('wp_head', 'add_rybbit_script_to_head');
+ ```
+ 4. Save the file. Ensure you replace `"YOUR_SITE_ID"` with your actual Rybbit Site ID.
+ </Tab>
+ <Tab>
+ **Modify `header.php` (For self-hosted WordPress with child theme, less common)**
+
+ You can also manually add the script to your theme's HTML header. This method is generally less preferred than using `functions.php` but is an option. It is **strongly recommended to make these changes in a child theme**. If you modify the parent theme files directly, your changes may be lost when the theme is updated.
+
+ 1. Go to **Appearance > Theme File Editor**. (Alternatively, edit the file via FTP/SFTP or your hosting file manager, which is safer if you are unfamiliar with editing theme files directly).
+ 2. Open your child theme's `header.php` file (or your parent theme's `header.php` if you are not using a child theme, with the above caution in mind).
+ 3. Paste your Rybbit tracking snippet right before the closing `</head>` tag:
+ ```html
+ <script
+ src="https://app.rybbit.io/api/script.js"
+ data-site-id="YOUR_SITE_ID" <!-- Replace YOUR_SITE_ID with your actual Site ID -->
+ async
+ defer
+ ></script>
+ ```
+ 4. Save the file. Ensure you replace `YOUR_SITE_ID` with your actual Rybbit Site ID.
+ </Tab>
+</Tabs>
+
+Remember to replace `"YOUR_SITE_ID"` in the snippets with your actual Site ID from your Rybbit dashboard.
\ No newline at end of file
diff --git a/docs-v2/src/components/PricingSection.tsx b/docs-v2/src/components/PricingSection.tsx
index a3519f69a..173b10962 100644
--- a/docs-v2/src/components/PricingSection.tsx
+++ b/docs-v2/src/components/PricingSection.tsx
@@ -61,7 +61,7 @@ function getFormattedPrice(eventLimit: number | string) {
export function PricingSection() {
const [eventLimitIndex, setEventLimitIndex] = useState(0); // Default to 100k (index 0)
- const [isAnnual, setIsAnnual] = useState(true);
+ const [isAnnual, setIsAnnual] = useState(false);
const eventLimit = EVENT_TIERS[eventLimitIndex];
const prices = getFormattedPrice(eventLimit);
@@ -196,7 +196,7 @@ export function PricingSection() {
? prices.monthly
: 0}
</span>
- <span className="ml-1 text-neutral-400">/month</span>
+ <span className="ml-1 text-neutral-400">{isAnnual ? "/year" : "/month"}</span>
</>
)}
</div>