This plugin utilizes an API to post additional events or page-views manually. Used mainly for goal and coversion tracking.
To use it, first you have to create GoogleAnalytics a service object:
<?php $gaService = \Plugin\GoogleAnalytics\JsService::instance(); ?>
or
<?php $gaService = \Plugin\GoogleAnalytics\PhpService::instance(); ?>
Js service uses JavaScript. That means the data will reach Google servers only on next pageview. Php service on the other hand will reach Google Analytics immediately, but Google will see it as a separate user and won't be able to associate previous actions with new event or pageview.
Track a pageview
<?php $gaService->trackEvent('/example.html'); ?>
'/example.html' may event not exist. But it has to start with a slash.
see https://developers.google.com/analytics/devguides/collection/analyticsjs/pages for more details
Track an event
<?php $gaService->trackEvent('Category', 'acttion', 'label', 'value'); ?>
see https://developers.google.com/analytics/devguides/collection/analyticsjs/events for more details
<<< IT MAY TAKE SEVERAL HOURS FOR NEW DATA TO APPEAR IN GOOGLE ANALYTICS! >>>