nystudio107 /
craft-instantanalytics-ga4
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Instant Analytics plugin for Craft CMS |
||
| 4 | * |
||
| 5 | * Instant Analytics brings full Google Analytics support to your Twig templates |
||
| 6 | * |
||
| 7 | * @link https://nystudio107.com |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 8 | * @copyright Copyright (c) 2017 nystudio107 |
||
|
0 ignored issues
–
show
|
|||
| 9 | */ |
||
|
0 ignored issues
–
show
|
|||
| 10 | |||
| 11 | namespace nystudio107\instantanalyticsGa4\controllers; |
||
| 12 | |||
| 13 | use craft\web\Controller; |
||
| 14 | use nystudio107\instantanalyticsGa4\InstantAnalytics; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * TrackController |
||
| 18 | * |
||
| 19 | * @author nystudio107 |
||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||
| 20 | * @package InstantAnalytics |
||
|
0 ignored issues
–
show
|
|||
| 21 | * @since 1.0.0 |
||
|
0 ignored issues
–
show
|
|||
| 22 | */ |
||
|
0 ignored issues
–
show
|
|||
| 23 | class TrackController extends Controller |
||
| 24 | { |
||
| 25 | // Protected Properties |
||
| 26 | // ========================================================================= |
||
| 27 | |||
| 28 | protected array|bool|int $allowAnonymous = [ |
||
| 29 | 'track-page-view-url', |
||
| 30 | 'track-event-url', |
||
| 31 | ]; |
||
| 32 | |||
| 33 | // Public Methods |
||
| 34 | // ========================================================================= |
||
| 35 | |||
| 36 | /** |
||
|
0 ignored issues
–
show
|
|||
| 37 | * @param string $url |
||
|
0 ignored issues
–
show
|
|||
| 38 | * @param string $title |
||
|
0 ignored issues
–
show
|
|||
| 39 | */ |
||
|
0 ignored issues
–
show
|
|||
| 40 | public function actionTrackPageViewUrl(string $url, string $title): void |
||
| 41 | { |
||
| 42 | InstantAnalytics::$plugin->ga4->addPageViewEvent($url, $title); |
||
| 43 | $this->redirect($url, 200); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
|
0 ignored issues
–
show
|
|||
| 47 | * @param string $url |
||
|
0 ignored issues
–
show
|
|||
| 48 | * @param string $eventName |
||
|
0 ignored issues
–
show
|
|||
| 49 | * @param array $params |
||
|
0 ignored issues
–
show
|
|||
| 50 | */ |
||
|
0 ignored issues
–
show
|
|||
| 51 | public function actionTrackEventUrl( |
||
| 52 | string $url, |
||
| 53 | string $eventName = '', |
||
| 54 | array $params = [], |
||
| 55 | ): void { |
||
| 56 | InstantAnalytics::$plugin->ga4->addSimpleEvent($url, $eventName, $params); |
||
| 57 | |||
| 58 | $this->redirect($url, 200); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |