AccylinDocs

WordPress

You can directly add Accylin Analytics to your WordPress site by editing the functions.php file in your theme.

Why Use functions.php?

While there are several methods to add custom JavaScript to your WordPress website, this way insures:

  • No Plugins Required: This method doesn't require installing any plugins, keeping your WordPress installation light.
  • Direct Control: You have full control over where and how the script is added.

Steps to Add the Script:

Locate the File

  • Go to Appearance > Theme Editor in your WordPress Dashboard.
  • In the right-hand sidebar, look for Theme Functions or functions.php. It is typically listed under Theme Files.
Important

Always back up your functions.php file before making any changes.

Edit the functions.php File

  • Open the functions.php file and scroll to the bottom (or wherever you feel comfortable adding the code).
  • Paste the following code:
function add_accylin_analytics_script() {
    // Replace the script below with the one copied from your website settings in Accylin
    ?>
    <script defer src="https://app.accylin.com/script.js" data-website-id="website-id" ></script>
    <?php
}
add_action('wp_head', 'add_accylin_analytics_script', 1); 
Warning

Make sure you replace the script section in the above code to match the code snippet provided in your website settings in Accylin.

After adding the code, click Update File to save the changes.

Explanation of the Code

The code uses the wp_head action hook to insert the script into the <head> html section of your WordPress pages.

The script is loaded last with the defer attribute, ensuring that it doesn't block the loading of other page elements.

Conclusion

By following these steps, you can easily add Accylin Analytics to your WordPress site. However, keep in mind that if you switch themes, you'll need to re-add the script to the new theme’s functions.php file.

Support

Need help? Contact us at support@accylin.com or visit our help center.

On this page