Skip to content

Instantly share code, notes, and snippets.

View latestscoop's full-sized avatar

Sami Cooper latestscoop

  • Cambridge, UK
View GitHub Profile
@latestscoop
latestscoop / explained.txt
Last active June 22, 2018 12:23
Google Analytics: Goals - Regular Expressions
All the following regex will pick up the goal trigger from a URL parameter on any page.
Example URL's with paramters: https://www.example.com/?id=value, http://www.example.com/cat/subcat/?id=value
This regex will pick up any of the following values; value,Value,ANYTHINGvalueANYTHING
Example URL's; http://www.example.com/?id=Value, http://www.example.com/?id=TEXTvalueTEXT,
.*(\?id=).*([v|V]alue).*
This regex will pick up the following values; value one, Value One, valueone, ValueOne, ANYTHINGvalueoneANYTHING
Example URL's; http://www.example.com/?id=Value One, http://www.example.com/cat/subcat/?id=TEXTvalue oneTEXT,
.*(\?id=).*([v|V]alue\s*[o|O]ne).*
@latestscoop
latestscoop / example.php
Last active June 20, 2018 08:28
PHP: On success inject JavaScript to redirect to another page (+ pass url parameter)
<?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>' ;
}
?>