-
Notifications
You must be signed in to change notification settings - Fork 0
/
GaOpOut.php
52 lines (41 loc) · 1.2 KB
/
GaOpOut.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
48
49
50
51
52
<?php
/**
* Created by PhpStorm.
* User: levani
* Date: 1/8/19
* Time: 1:39 PM
*/
namespace apollo11\yii2GaOptOut;
use yii\base\Widget;
class GaOpOut extends Widget
{
// view
public $view;
//gap Id
public $gaAppId;
//output call event
public $optOutCallEvent = 'click';
//element selector with link to jsoutput
public $elementSelector = '[href="#jsgaoptout"]';
//Alert message on disable
public $alertMessage = 'Google Analytics tracking has been deactivated in your browser for this website.';
/**
* @var bool
*/
public $debug = false;
public $showAlterAfterDeactivate = true;
public function init()
{
AssetBundle::register($this->getView());
$this->getView()->registerJs("
new ApGaOptOut({
gaAppId: '{$this->gaAppId}',
optOutCallEvent: '{$this->optOutCallEvent}',
elementSelector: '{$this->elementSelector}',
debug: " . ($this->debug ? 'true' : 'false') . ",
showAlterAfterDeactivate: " . ($this->showAlterAfterDeactivate ? 'true' : 'false') . ",
alterMessage: '{$this->alertMessage}'
});
");
}
}