Hey @nolesnyc – Thank you a lot for your message, as well as for your interest in our plugin. ??
It surely can help with it, even tho the feature you requested is not included within the default functionality of the plugin.
To make it work, here’s what you need to do:
1. Activate the Send Data On Custom Action webhook trigger
2. Add a new webhook URL where you want to send the data to and as a webhook name, please include send_on_pageview
3. Please paste the following code into your functions.php file:
add_shortcode( 'WPWH_FIRE_ON_SITE_VIEW', 'wpwh_fire_webhook_on_site_view' );
function wpwh_fire_webhook_on_site_view( $attr = array(), $content = '' ){
//Prevent the hook from being fired in the backend
if( is_admin() ){
return '';
}
$custom_data = array(
'page_url' => (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"
);
$webhook_names = array(
'send_on_pageview'
);
$http_args = array(
'blocking' => false //Set this to true to receive the response
);
$response = apply_filters( 'wp_webhooks_send_to_webhook_filter', array(), $custom_data, $webhook_names, $http_args );
return '';
}
4. Once that’s done, simply paste the following shortcode on the site you would like to send the webhook from: [WPWH_FIRE_ON_SITE_VIEW]
Wherever you post this shortcode, the webhook trigger will be fired. The code above includes some functionality that adds only the URL to the payload of the receiving service. The URL value hast the argument(key) page_url.
In case you have any further questions, feel free to let me know at any time. ??