coresocial-tracking-success

Developer Knowledge Level

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!

JS
Action identifier (JavaScript)
do_action( "coresocial-tracking-success", result, link );
Arguments
Name
Type
Description
result
object
Successful endpoint response: status and optional count (string or number) and uid.
link
HTMLAnchorElement
Original tracked button link.

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 );
} );
Rate this reference
0
0
2

You are not allowed to rate this post.

Leave a Comment

0
0
0
0
0
0
0
0
0