diff --git a/README.md b/README.md index f0e060d..a3cdfb6 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Then edit `analytics.php` in `config` to your needs. We do config merge in the s
tracking_id
Tracking ID
tracking_domain
Tracking domain, unset or set to "auto" for automatic fallback
+
tracker_name
Tracker name
display_features
enabling the display features plugin, possible values: (true|false)
anonymize_ip
anonymize users ip, possible values: (true|false)
auto_track
auto tracking current pageview, possible values: (true|false)
@@ -543,4 +544,4 @@ Returns the nonce generated for the Content Security Policy Header. */ public function cspNonce(); -Available since 1.3.0. \ No newline at end of file +Available since 1.3.0. diff --git a/src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php b/src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php index 92c8fcc..09a46c1 100644 --- a/src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php +++ b/src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php @@ -31,6 +31,13 @@ class GoogleAnalytics implements AnalyticsProviderInterface */ private $trackingDomain; + /** + * tracker name + * + * @var string + */ + private $trackerName; + /** * display features plugin enabled or disabled * @@ -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); @@ -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) { diff --git a/src/config/analytics.php b/src/config/analytics.php index ae24584..71c095a 100644 --- a/src/config/analytics.php +++ b/src/config/analytics.php @@ -33,6 +33,11 @@ */ 'tracking_domain' => 'auto', + /** + * Tracker Name + */ + 'tracker_name' => 't0', + /** * enabling the display feature plugin */