Track the referer path for visitors in silverstripe
- Save the folder referer-tracker in your site root
- Or add the folowing to your composer.json
"cyberduck/referer-tracker": "dev-master"
- Run a dev/build?flush=1
- Add the following tracking code to the init function of your Page.php
public function init() {
parent::init();
$this->refererTracker = new refererTracker(function($a, $b) { return \Session::set($a, $b); }, function ($q) { return \Session::get($q); } );
$this->refererTracker->log();
}
Returns all referers which are deemed "internal"
$this->refererTracker->retrieveInternal()
Returns all referers which are deemed "external"
$this->refererTracker->retrieveExternal()
Convenience method which returns a single, merged array of the above
$this->refererTracker->retrieveAll()