coresocial-tracking-success
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 after an OK tracking response and before count-display updates. Fires for hidden counts, zero counts, missing wrappers, and removed buttons. It means the endpoint returned OK, not that a new like was recorded or an external share completed. Listener exceptions are outside tracking error handling.
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-success', 'my-site/tracking', function ( result, link ) {
console.log( link.dataset.network, result.count );
} );