Rybbit
Integration Guides

WordPress

Integrate Rybbit Analytics with your WordPress site

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.

Rybbit WordPress Plugin (Recommended for ease of use)

You can find our community-maintained WordPress plugin as well as installation instructions here. This is often the simplest method for most users.

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 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.
    <script
      src="https://app.rybbit.io/api/script.js"
      data-site-id="YOUR_SITE_ID"
      async
      defer
    ></script>
  4. Save your changes.

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:
    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.

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:
    <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.

Remember to replace "YOUR_SITE_ID" in the snippets with your actual Site ID from your Rybbit dashboard.