Last active
April 2, 2019 01:11
-
-
Save codiller/2f89d73555a4a3c14c45a1d0f5f93916 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
<?php | |
/* | |
* | |
* Website tracking for ActiveCampaign | |
* | |
*/ | |
add_filter('wp_head', 'tlc_ac_tracking_email'); | |
function tlc_ac_tracking_email() { | |
$email = htmlspecialchars( $_COOKIE['email'] ); | |
echo '<script type="text/javascript"> | |
var trackcmp_email = "' . $email . '"; | |
var trackcmp = document.createElement("script"); | |
trackcmp.async = true; | |
trackcmp.type = "text/javascript"; | |
trackcmp.src = "//trackcmp.net/visit?actid=YOURACIDHERE&e="+encodeURIComponent(trackcmp_email)+"&r="+encodeURIComponent(document.referrer)+"&u="+encodeURIComponent(window.location.href); | |
var trackcmp_s = document.getElementsByTagName("script"); | |
if (trackcmp_s.length) { | |
trackcmp_s[0].parentNode.appendChild(trackcmp); | |
} else { | |
var trackcmp_h = document.getElementsByTagName("head"); | |
trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp); | |
} | |
</script>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment