Title: BUG &#8211; Tracking code removed on deactivation
Last modified: June 15, 2026

---

# BUG – Tracking code removed on deactivation

 *  [Marko Dimitrijević](https://wordpress.org/support/users/dimikjones/)
 * (@dimikjones)
 * [3 weeks, 1 day ago](https://wordpress.org/support/topic/bug-tracking-code-removed-on-deactivation/)
 * Hello,
   I saw that you didn’t address this one [https://wordpress.org/support/topic/deactivation-loses-the-code/](https://wordpress.org/support/topic/deactivation-loses-the-code/)
   and it is basically same thing. You are not using deactivation hook properly 
   since it should be used to clear temp data: “The deactivation hook is sometimes
   confused with the [uninstall hook](https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/).
   The uninstall hook is best suited to **delete all data permanently** such as 
   deleting plugin options and custom tables, etc.”In your plugin when it is DEACTIVATED
   it also remove all tracking codes which is incovinient for end user having to
   copy code again from your platform and in most cases it can be temporary deactivations
   maybe for periods of time wher tracking doesn’t need to run or when debugging
   something or else…You can use suggested approach from WordPress documentation
   with uninstall.php file [https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/](https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/)
 * Or, alternative one using `register_uninstall_hook()` with your existing class:
 * **Changes to `plerdy_heatmap_tracking.php`:**
 * **1. Modify line 36 – change hook type and make it static:**
 *     ```wp-block-code
       // REPLACE:register_deactivation_hook(__FILE__, array( $this, 'delete_option' ) );// WITH (register_uninstall_hook cannot use $this because the class instance doesn't exist during uninstall.):register_uninstall_hook(__FILE__, array( 'Plerdy', 'uninstall' ) );
       ```
   
 * **2. Modify lines 48-51 – rename method, make it static, add `checkbox` cleanup:**
 *     ```wp-block-code
       // REPLACE:
       public function delete_option($order_id) {
           delete_option('plerdy_tracking_script');
           delete_option('plerdy_abtracking_script');
       }
   
       // WITH:
       public static function uninstall() {
           delete_option('plerdy_tracking_script');
           delete_option('plerdy_abtracking_script');
           delete_option('checkbox');
       }
       ```
   
 * When we are at it also consider changing ‘checkbox’ since it is too generic, 
   it needs to be prefixed e.g. plerdy_collect_commerce_data or somethihg like that.

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fbug-tracking-code-removed-on-deactivation%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/plerdy-heatmap/assets/icon-256x256.png?rev=3328062)
 * [Website Optimization – Plerdy](https://wordpress.org/plugins/plerdy-heatmap/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/plerdy-heatmap/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/plerdy-heatmap/)
 * [Active Topics](https://wordpress.org/support/plugin/plerdy-heatmap/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/plerdy-heatmap/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/plerdy-heatmap/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Marko Dimitrijević](https://wordpress.org/support/users/dimikjones/)
 * Last activity: [3 weeks, 1 day ago](https://wordpress.org/support/topic/bug-tracking-code-removed-on-deactivation/)
 * Status: not resolved