Created
May 7, 2018 18:32
-
-
Save tomfinitely/8ccb8cb7db0b1ddf661f41c2f24d52cc to your computer and use it in GitHub Desktop.
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
/** | |
* Finds all Pardot form iframes and appends a ?embedded_on= query parameter to the source. | |
* Very useful for fixing the crappy issues with pardot tracking... | |
*/ | |
add_filter( 'pardot_content', 'pardot_iframe_src_filter', 99, 1 ); | |
function pardot_iframe_src_filter( $content ) { | |
global $post; | |
$permalink_path = wp_make_link_relative( get_permalink( $post->ID ) ); | |
$ga = ( isset( $_COOKIE['_ga'] ) && ! empty( $_COOKIE['_ga'] ) ) ? $_COOKIE['_ga'] : null; | |
$content = preg_replace( '#\<iframe(.*?)\ssrc\=\"http(s)?:\/\/(www2\.alliedtelecom\.net|go\.pardot\.com)(.*?)\"(.*?)\>#i', '<iframe$1 src="https://go.pardot.com$4/?embedded_on=' . urlencode( $permalink_path ) . '&embedPageName=' . urlencode( $post->post_title ) . ( $ga ? '&_ga=' . urlencode( $ga ) : '' ) . '"$5>', $content ); | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment