Last active
December 22, 2022 20:12
-
-
Save cliffordp/f90a50390f51e98457512a36d02f1ef3 to your computer and use it in GitHub Desktop.
NotificationX plugin: Custom link location for Google Analytics sourced notifications (default is homepage)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* NotificationX plugin: Custom link location for Google Analytics sourced notifications (default is homepage). | |
* | |
* @link https://gist.github.com/cliffordp/f90a50390f51e98457512a36d02f1ef3 This snippet. | |
* | |
* @see \NotificationX\FrontEnd\FrontEnd::link_url | |
*/ | |
add_filter( 'nx_notification_link_google', function( $link, $post, $entry ){ | |
// !!! CHANGE THIS TO YOUR "CONTACT US" PAGE ID !!! | |
$target_page_id = 88; | |
/* | |
error_log( 'LINK' ); | |
error_log( $link ); | |
error_log( 'POST' ); | |
error_log( print_r( $post, true ) ); | |
error_log( 'ENTRY' ); | |
error_log( print_r( $entry, true ) ); | |
*/ | |
$new_link = add_query_arg( [ | |
'utm_id' => $post['id'], // The Notification's ID. | |
// Not possible as NotificationX's REST request does not include it. | |
//'utm_content' => 'from_id-' . get_queried_object_id(), | |
'utm_source' => 'fomo', | |
'utm_medium' => 'popup', | |
'utm_campaign' => 'notificationx', | |
], get_permalink( $target_page_id ) ); | |
return esc_url_raw( $new_link ); | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment