Last active
June 20, 2018 08:28
-
-
Save latestscoop/444a586c508725ecd2cea73ed56af4f1 to your computer and use it in GitHub Desktop.
PHP: On success inject JavaScript to redirect to another page (+ pass url parameter)
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 | |
//pass a value to url parameter called param | |
$value = 'value'; | |
//on success (eg: form sent) $var='trigger' | |
if ($var=='trigger'){ | |
//redirect to url after 2 seconds | |
echo '<script type="text/JavaScript">' . 'setTimeout("location.href =' . " 'http://www.example.com/?param=" . $value . "';" . '",2000);' . '</script>' ; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create a Google Analytics Goal with regex to pick up the URL parameter and value, select; Admin > Account > Property > Goals
Regular expression examples: https://gist.github.com/latestscoop/7eb4e5c216230bebe209e9aaa16c4894
Import the goal to Google AdWords as a completion metric, select; Tools > Measurement > Conversions > Add > Import (from GA)