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.
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.
- 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).
- Open your child theme's
functions.php
file (or your parent theme'sfunctions.php
if you are not using a child theme, with the above caution in mind). - 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');
- 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.
- 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).
- Open your child theme's
header.php
file (or your parent theme'sheader.php
if you are not using a child theme, with the above caution in mind). - 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>
- 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.