-
-
Save andreas-marschke/41d47c9cfeebbcee8fb2 to your computer and use it in GitHub Desktop.
b.js - Boomerang Setup in around 500 bytes
This file contains hidden or 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
/* b.js - Boomerang Setup in around 500 bytes | |
* ------------------------------------------ | |
* Complete boomerang.js initialization with essential plugins in around 500 bytes | |
* It mimics "Google Analytics"-style script injection using document.createElement | |
* and document.head.appendChild(). | |
* | |
* Beacon URL configuration + configuring Plugins as a variable to the beacon: | |
* | |
* http://boomerang.example.org/beacon/0000/dashboard/start?plugins=BW%7CRT%7Cnavtimin%7Crestiming&... | |
* | |
* Checkout the boomerang project at: github.com/lognormal/boomerang | |
* and my Boomerang reciever Server: github.com/andreas-marschke/boomerang-express | |
*/ | |
(function(b,d){var a=["//boomerang.example.org/","0000/dashboard/start","plugins","BOOMR"],c=d.createElement("script");c.src="/js/boomerang.js";d.head.appendChild(c);c.onload=function(){b[a[5]].init({beacon_url:a[0]+"beacon/"+a[1],DNS:{base_url:a[0],strict_referrer:!1},BW:{base_url:a[0],cookie:"bandwidth",nruns:1},RT:{},ipv6:{},clicks:{click_url:a[0]+"click/"+a[1],onbeforeunload:!0}});b[a[3]].addVar(a[2],Object.keys(b[a[3]][a[2]]).join("|"))}})(this,this.document); |
And I sort of solve the init
part by just calling it at the bottom of my combined & minified boomerang.js
file
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, a few comments:
c.onload
to call init. I've seen cases where a script's onload event does not fire. Instead, subscribe to the custom eventonBoomerangLoaded
(or maybe do both)addVar
before callinginit
. I've seen cases where init fires the beacon before addVar runs.strict_referrer
is not part of theDNS
plugin ;)