-
-
Notifications
You must be signed in to change notification settings - Fork 13
Tracker
The Tracker client can be used to add web analytics tracking functions to your application.
<?php require_once('owa-php-sdk/owa-autoloader.php');
$config = [
'instance_url' => 'http://your.domain.com/owa/'
];
$sdk = new OwaSdk\sdk($config);
$tracker = $sdk->createTracker();
?>
the siteID is the unique ID of the tracked website/application in OWA. A siteID is required in order to ensure that tracking events associated with the proper tracked website. Tracked websites can be added to your OWA Instance via the admin interface (Settings > Sites), the REST API, or the CLI. See the OWA Core wiki.
To set the siteID in the tracker:
$tracker->setSiteId('your-siteId');
You can set various page attributes including the page title and page type. Page title can be whatever string you want but generally should correspond to the HTML <title>
tag of the page being tracked.
$tracker->setPageTitle('Your Page Title');
Page type is a dimension used to rollup groups of pages in OWA reporting. It can be whatever string you want but some forethought should be given to how to want to group pages.
$tracker->setPageType('your_page_type');
Once the siteId and any page attributes are set you are ready to track the page view.
$tracker->trackPageView();
Action Tracking provides a way to track actions that users perform on your website. An action could anything ranging from the completion of a web form to clicking on a particular link or UI control.
Actions are reported separately from pages views and have their own metrics & dimensions in OWA reporting.
Actions have a few properties that you can set during tracking.
Param | Type | Description |
---|---|---|
Name | string | Actions can be given any name you want. Each unique action name will result in a unique type of action. For example let's pretend that we have a an action called "Recipe Print" which would be triggered whenever a users clicked on the print icon on one of our pretend recipe web pages. |
Group | string | It is possible to group actions for purposes of reporting. It might be helpful to group on "Recipe Print" action under the action group called "Cooking". |
Label | string | optional. Sometimes just looking at actions by name or group is does not provide enough detail. That's where labels come in. For example, let's say that we wanted to see which recipe's were being printed. To accomplish this we could assign a label to the action. In this case the label could be the name title of the recipe, say "Italian Chicken Soup". |
Numeric Value | integer | optional. Actions can have a numeric value associated with them. This value will display summarized in reporting. |
The trackAction
method issued to track an action. It should be called after trackPageView
.
$owa->trackAction("action_name", "action_group", "action_label", numeric_value);
$owa->trackAction('Cooking', 'Recipe Print', 'Italian Chicken Soup');
Action with a numeric value:
$owa->trackAction('Cooking', 'Recipe Print', 'Italian Chicken Soup', 10);