-
Notifications
You must be signed in to change notification settings - Fork 2
/
JsService.php
47 lines (38 loc) · 912 Bytes
/
JsService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* @package ImpressPages
*/
/**
* Created by PhpStorm.
* User: mangirdas
* Date: 15.1.4
* Time: 22.14
*/
namespace Plugin\GoogleAnalytics;
/**
* Track event or pageviews using JavaScript API. That means the event will be actually registered on the next page load.
* Class JsService
* @package Plugin\GoogleAnalytics
*/
class JsService
{
protected function __construct()
{
}
public static function instance() {
return new JsService();
}
public function trackEvent($category, $action, $label = null, $value = null)
{
$_SESSION['GoogleAnalytics']['trackEvent'][] = array(
'category' => $category,
'action' => $action,
'label' => $label,
'value' => $value
);
}
public function trackPageview($path)
{
$_SESSION['GoogleAnalytics']['trackPageview'][] = $path;
}
}