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

Commit 8fbf83a

Browse files
author
Robert Kummer
authored
Merge pull request #38 from WaveHack/master
Add tracker name
2 parents 35193df + 789b8b4 commit 8fbf83a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Then edit `analytics.php` in `config` to your needs. We do config merge in the s
6464
<dl>
6565
<dt>tracking_id</dt><dd>Tracking ID</dd>
6666
<dt>tracking_domain</dt><dd>Tracking domain, unset or set to "<code>auto</code>" for automatic fallback</dd>
67+
<dt>tracker_name</dt><dd>Tracker name</dd>
6768
<dt>display_features</dt><dd>enabling the display features plugin, possible values: <code>(true|false)</code></dd>
6869
<dt>anonymize_ip</dt><dd>anonymize users ip, possible values: <code>(true|false)</code></dd>
6970
<dt>auto_track</dt><dd>auto tracking current pageview, possible values: <code>(true|false)</code></dd>
@@ -543,4 +544,4 @@ Returns the nonce generated for the Content Security Policy Header.
543544
*/
544545
public function cspNonce();
545546

546-
Available since 1.3.0.
547+
Available since 1.3.0.

src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ class GoogleAnalytics implements AnalyticsProviderInterface
3131
*/
3232
private $trackingDomain;
3333

34+
/**
35+
* tracker name
36+
*
37+
* @var string
38+
*/
39+
private $trackerName;
40+
3441
/**
3542
* display features plugin enabled or disabled
3643
*
@@ -126,6 +133,7 @@ public function __construct(array $options = [])
126133
{
127134
$this->trackingId = array_get($options, 'tracking_id');
128135
$this->trackingDomain = array_get($options, 'tracking_domain', 'auto');
136+
$this->trackerName = array_get($options, 'tracker_name', 't0');
129137
$this->displayFeatures = array_get($options, 'display_features', false);
130138
$this->anonymizeIp = array_get($options, 'anonymize_ip', false);
131139
$this->autoTrack = array_get($options, 'auto_track', false);
@@ -403,9 +411,9 @@ public function render()
403411
: sprintf(", {'userId': '%s'}", $this->userId);
404412

405413
if ($this->debug || App::environment('local')) {
406-
$script[] = "ga('create', '{$this->trackingId}', { 'cookieDomain': 'none' }{$trackingUserId});";
414+
$script[] = "ga('create', '{$this->trackingId}', { 'cookieDomain': 'none' }, '{$this->trackerName}'{$trackingUserId});";
407415
} else {
408-
$script[] = "ga('create', '{$this->trackingId}', '{$this->trackingDomain}'{$trackingUserId});";
416+
$script[] = "ga('create', '{$this->trackingId}', '{$this->trackingDomain}', '{$this->trackerName}'{$trackingUserId});";
409417
}
410418

411419
if ($this->ecommerceTracking) {

src/config/analytics.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
*/
3434
'tracking_domain' => 'auto',
3535

36+
/**
37+
* Tracker Name
38+
*/
39+
'tracker_name' => 't0',
40+
3641
/**
3742
* enabling the display feature plugin
3843
*/

0 commit comments

Comments
 (0)