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

Commit c38c967

Browse files
committed
Add tracker name
1 parent 35193df commit c38c967

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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) {

0 commit comments

Comments
 (0)