DumbData Code Solution For Deactivating "stg.timer" and "stg.leaveContent" Events In Piwik Pro

Here is the code you can insert above the Piwik Pro tracking script to attempt to disable the execution of the “stg.timer” and “stg.leaveContent” dataLayer events. It’s important to note that, on rare occasions, you might observe an initial triggering of these events before the deactivation takes effect. This does not indicate a malfunction; rather, it’s an occasional odd behaviour that can occur due to the way Piwik Pro’s code operates.

Should you have any questions or require assistance with Piwik Pro, please feel free to contact us via the DumBdata email at team@dumbdata.co.

  // Step 1: Initialize dataLayer
  window.dataLayer = window.dataLayer || [];
  // step 2: is the code block for deactivating these Piwik Pro dataLayer events
	function initializeDeactivationScript() {
    // I wrapped the deactivation function in a another function for easy later reference
    (function() {
      var originalPush = window.dataLayer.push;
      window.dataLayer.push = function() {
        var args = Array.prototype.slice.call(arguments);
        var filteredArgs = args.filter(function(arg) {
          if (arg.event) {
            var deactivateEvents = ['stg.leaveContent', 'stg.timer'];
            if (deactivateEvents.indexOf(arg.event) !== -1) {
              console.log('Deactivated event:', arg.event);
              return false;
          return true;
        if (filteredArgs.length > 0) {
          originalPush.apply(window.dataLayer, filteredArgs);
    // Your deactivation logic
      'event': 'deactivation_inplace'

  // Execute immediately

  // Also execute on window load due to known weird behaviour
  	window.addEventListener('load', initializeDeactivationScript);



The code helps you move from this πŸ‘‡πŸΏ

To this, where the dataLayer events are now disabledπŸ‘‡πŸΏ

πŸš€ We've got more FREE measurement resources for you and your team😎 .