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

Commit 8c42dea

Browse files
author
Robert Kummer
authored
added fluent interface to setCustom()
1 parent 213e835 commit 8c42dea

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,21 +583,24 @@ public function unsetUserId()
583583
}
584584

585585
/**
586-
* sets custom dimension/s
587-
* @param string /array $dimension
586+
* sets custom dimensions
587+
*
588+
* @param string|array $dimension
588589
* @param string $value
589-
* @return void
590+
* @return AnalyticsProviderInterface
590591
*/
591592
public function setCustom($dimension, $value = null)
592593
{
593-
if (!$value && is_array($dimension)) {
594+
if ($value === null && is_array($dimension)) {
594595
$params = json_encode($dimension);
595-
$trackingCode = "ga('set',$params);";
596+
$trackingCode = "ga('set', $params);";
596597
} else {
597598
$trackingCode = "ga('set', '$dimension', '$value');";
598599
}
599600

600601
$this->trackCustom($trackingCode);
602+
603+
return $this;
601604
}
602605

603606
/**

0 commit comments

Comments
 (0)