Home » Beetle Tracking » Advanced » Custom design for cookiebanner

Custom design for cookiebanner by overriding templates in Beetle Tracking


Beetle Tracking allows you to override its template files in a safe, upgrade-proof way. Currently, the plugin includes one template file: consent-modal.php, which can be customized to match your website’s design and functionality requirements.

Why use template overrides?

Directly editing plugin files can cause problems:

  • Updates: Any changes made directly to the plugin will be overwritten when the plugin updates, as the process replaces the entire plugin directory with a new version.
  • Errors: Modifications made directly to the plugin could introduce errors that affect your site’s functionality.

Instead, the recommended method is to use template overrides. This approach ensures your changes remain intact even after updates to Beetle Tracking.

How to override Beetle Tracking templates

To override the consent-modal.php file, follow these steps:

  1. Locate the Template File:
    The original template file is located at:
    wp-content/plugins/beetle-tracking-pro/templates/consent-modal.php
  2. Create a Beetle Tracking Template Directory in Your Theme
    In your theme folder (or child theme folder, if you’re using one), create a new folder named beetle-tracking.
    For example:
    wp-content/themes/your-theme/beetle-tracking/
  3. Copy the Template File
    Copy the consent-modal.php file from the plugin’s template folder into your newly created beetle-tracking folder in your theme directory.
    For example:
    wp-content/themes/your-theme/beetle-tracking/consent-modal.php
  4. Customize the Copied File
    Open the copied consent-modal.php file in your code editor and make your desired changes. These changes will override the default plugin template

What happens next?

When Beetle Tracking looks for the consent-modal.php file, it will first check if a version exists in the theme folder (/beetle-tracking/). If it finds one, it will use that version instead of the default file in the plugin directory. If no override exists, it will fall back to the plugin’s default template.

This method ensures your customizations are upgrade-safe and won’t be affected by updates to Beetle Tracking.

Notes

  • If Beetle Tracking releases updates that affect the consent-modal.php template, it’s a good idea to review the changes in the plugin’s default template file and update your overridden version if necessary.
  • Always test your customizations on a staging site before applying them to a live site.

© Rocket Beetle 2023