Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #38 from WaveHack/master
Browse files Browse the repository at this point in the history
Add tracker name
  • Loading branch information
Robert Kummer authored Jan 26, 2017
2 parents 35193df + 789b8b4 commit 8fbf83a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Then edit `analytics.php` in `config` to your needs. We do config merge in the s
<dl>
<dt>tracking_id</dt><dd>Tracking ID</dd>
<dt>tracking_domain</dt><dd>Tracking domain, unset or set to "<code>auto</code>" for automatic fallback</dd>
<dt>tracker_name</dt><dd>Tracker name</dd>
<dt>display_features</dt><dd>enabling the display features plugin, possible values: <code>(true|false)</code></dd>
<dt>anonymize_ip</dt><dd>anonymize users ip, possible values: <code>(true|false)</code></dd>
<dt>auto_track</dt><dd>auto tracking current pageview, possible values: <code>(true|false)</code></dd>
Expand Down Expand Up @@ -543,4 +544,4 @@ Returns the nonce generated for the Content Security Policy Header.
*/
public function cspNonce();

Available since 1.3.0.
Available since 1.3.0.
12 changes: 10 additions & 2 deletions src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class GoogleAnalytics implements AnalyticsProviderInterface
*/
private $trackingDomain;

/**
* tracker name
*
* @var string
*/
private $trackerName;

/**
* display features plugin enabled or disabled
*
Expand Down Expand Up @@ -126,6 +133,7 @@ public function __construct(array $options = [])
{
$this->trackingId = array_get($options, 'tracking_id');
$this->trackingDomain = array_get($options, 'tracking_domain', 'auto');
$this->trackerName = array_get($options, 'tracker_name', 't0');
$this->displayFeatures = array_get($options, 'display_features', false);
$this->anonymizeIp = array_get($options, 'anonymize_ip', false);
$this->autoTrack = array_get($options, 'auto_track', false);
Expand Down Expand Up @@ -403,9 +411,9 @@ public function render()
: sprintf(", {'userId': '%s'}", $this->userId);

if ($this->debug || App::environment('local')) {
$script[] = "ga('create', '{$this->trackingId}', { 'cookieDomain': 'none' }{$trackingUserId});";
$script[] = "ga('create', '{$this->trackingId}', { 'cookieDomain': 'none' }, '{$this->trackerName}'{$trackingUserId});";
} else {
$script[] = "ga('create', '{$this->trackingId}', '{$this->trackingDomain}'{$trackingUserId});";
$script[] = "ga('create', '{$this->trackingId}', '{$this->trackingDomain}', '{$this->trackerName}'{$trackingUserId});";
}

if ($this->ecommerceTracking) {
Expand Down
5 changes: 5 additions & 0 deletions src/config/analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
*/
'tracking_domain' => 'auto',

/**
* Tracker Name
*/
'tracker_name' => 't0',

/**
* enabling the display feature plugin
*/
Expand Down

0 comments on commit 8fbf83a

Please sign in to comment.