Skip to content

Instantly share code, notes, and snippets.

@outmost
Last active December 17, 2015 01:58
Show Gist options
  • Save outmost/5531902 to your computer and use it in GitHub Desktop.
Save outmost/5531902 to your computer and use it in GitHub Desktop.
Example Boomerang custom variables with PHP to get request IP and User Agent, javascript to get domain.
/* http://lognormal.github.io/boomerang/doc/howtos/howto-5.html */
<script type="text/javascript">
BOOMR.init({
beacon_url: "http://yoursite.com/path/to/beacon"
});
var domain = location.hostname;
BOOMR.addVar({
"ip": "<?
if (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else
$ip = "UNKNOWN";
echo "$ip";
?>",
"user_agent": "<?
$browser_type = getenv("HTTP_USER_AGENT");
echo "$browser_type";
?>",
"domain": domain
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment