coresocial-tracking-error

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-error", error, link );
Arguments
Name
Type
Description
error
unknown
Caught fetch, JSON, HTTP, or tracking-response error.
link
HTMLAnchorElement
Original tracked button link.

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 );
} );
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