coresocial-tracking-error
This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!
Action identifier (JavaScript)
Arguments
JavaScript wp.hooks action for a failed fetch, JSON parse, HTTP response, or rejected tracking response. Runs after the original console error is logged and before the tracking function returns. It does not report listener exceptions or clipboard failures.
Register with wp.hooks.addAction(), using a unique namespace. Enqueue the listener with wp-hooks and coresocial-main dependencies before the interaction. The Source Code block uses a generic action template; the example shows the JavaScript API. Keep listeners lightweight and handle their own errors.
Example
wp.hooks.addAction( 'coresocial-tracking-error', 'my-site/tracking', function ( error, link ) {
console.log( 'Tracking failed for', link.dataset.network );
} );