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

Commit 7d80413

Browse files
author
Robert Kummer
committed
Merge pull request #29 from amirbilu/support-setting-custom-dimension
allowing setting of custom dimensions using key-value array, or singl…
2 parents 9f8ce5f + a25ab83 commit 7d80413

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,22 @@ public function unsetUserId()
431431
{
432432
return $this->setUserId(null);
433433
}
434+
435+
/**
436+
* sets custom dimension/s
437+
* @param string/array $dimension
438+
* @param string $value
439+
* @return void
440+
*/
441+
public function setCustom($dimension, $value=null){
442+
if(!$value && is_array($dimension)){
443+
$params = json_encode($dimension);
444+
$trackingCode = "ga('set',$params);";
445+
}
446+
else{
447+
$trackingCode = "ga('set', '$dimension', '$value');";
448+
}
449+
450+
$this->trackCustom($trackingCode);
451+
}
434452
}

0 commit comments

Comments
 (0)