Matomo
extends AbstractHelper
in package
Matomo web analytics view helper for Matomo versions >= 4
Tags
Table of Contents
- $context : string
- Tracker initialization context ('', 'lightbox', 'accordion' or 'tabs')
- $customDimensions : array<string|int, mixed>
- Mappings from data fields to custom dimensions for tracking additional information
- $customVars : bool
- Whether to use custom variables to track additional information
- $disableCookies : bool
- Whether to disable cookies (see config.ini for details)
- $params : array<string|int, mixed>
- Additional parameters
- $request : Request
- Request object
- $router : RouteMatch
- Router object
- $searchPrefix : string
- Search prefix (see config.ini for details)
- $siteId : int
- Matomo Site ID
- $timestamp : int
- A timestamp used to identify the init function to avoid name clashes when opening lightboxes.
- $url : string
- Matomo URL (empty if disabled)
- __construct() : mixed
- Constructor
- __invoke() : string
- Returns Matomo code (if active) or empty string if not.
- getClosingTrackingCode() : string
- Get the Finalization Part of the Tracking Code
- getCombinedSearchResults() : array<string|int, mixed>|null
- Get Combined Search Results if on a Results Page
- getCustomDimensionsCode() : string
- Convert a custom data array to JavaScript dimensions code
- getCustomVarsCode() : string
- Convert a custom data array to JavaScript code
- getGenericCustomData() : array<string|int, mixed>
- Get custom data for a generic page view
- getInitFunctionName() : string
- Get name of JS init function
- getLightboxCustomData() : array<string|int, mixed>
- Get custom data for lightbox actions
- getOpeningTrackingCode() : string
- Get the Initialization Part of the Tracking Code
- getPageUrl() : string
- Get the URL for the current page
- getRecordDriver() : AbstractBase|null
- Get Record Driver if on a Record Page
- getRecordPageCustomData() : array<string|int, mixed>
- Get custom data for record page
- getSearchCustomData() : array<string|int, mixed>
- Get custom data for search results
- getSearchResults() : Results|null
- Get Search Results if on a Results Page
- getTrackCombinedSearchCode() : string
- Get site search tracking code for combined search
- getTrackerJsUrl() : string
- Get Matomo tracker JS URL
- getTrackerUrl() : string
- Get Matomo tracker URL
- getTrackPageViewCode() : string
- Get Page View Tracking Code
- getTrackSearchCode() : string
- Get Site Search Tracking Code
- trackCombinedSearch() : string
- Track a Combined Search
- trackPageView() : string
- Track a Generic Page View
- trackRecordPage() : string
- Track a Record View
- trackSearch() : string
- Track a Search
Properties
$context
Tracker initialization context ('', 'lightbox', 'accordion' or 'tabs')
protected
string
$context
= ''
$customDimensions
Mappings from data fields to custom dimensions for tracking additional information
protected
array<string|int, mixed>
$customDimensions
$customVars
Whether to use custom variables to track additional information
protected
bool
$customVars
$disableCookies
Whether to disable cookies (see config.ini for details)
protected
bool
$disableCookies
$params
Additional parameters
protected
array<string|int, mixed>
$params
= []
$request
Request object
protected
Request
$request
$router
Router object
protected
RouteMatch
$router
$searchPrefix
Search prefix (see config.ini for details)
protected
string
$searchPrefix
$siteId
Matomo Site ID
protected
int
$siteId
$timestamp
A timestamp used to identify the init function to avoid name clashes when opening lightboxes.
protected
int
$timestamp
$url
Matomo URL (empty if disabled)
protected
string
$url
Methods
__construct()
Constructor
public
__construct(Config $config, TreeRouteStack $router, Request $request) : mixed
Parameters
- $config : Config
-
VuFind configuration
- $router : TreeRouteStack
-
Router
- $request : Request
-
Request
Return values
mixed —__invoke()
Returns Matomo code (if active) or empty string if not.
public
__invoke([array<string|int, mixed> $params = [] ]) : string
Parameters
- $params : array<string|int, mixed> = []
-
Parameters
Return values
string —getClosingTrackingCode()
Get the Finalization Part of the Tracking Code
protected
getClosingTrackingCode() : string
Return values
string —JavaScript Code Fragment
getCombinedSearchResults()
Get Combined Search Results if on a Results Page
protected
getCombinedSearchResults() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Array of search results or null if not on a combined search page
getCustomDimensionsCode()
Convert a custom data array to JavaScript dimensions code
protected
getCustomDimensionsCode(array<string|int, mixed> $customData) : string
Parameters
- $customData : array<string|int, mixed>
-
Custom data
Return values
string —JavaScript Code Fragment
getCustomVarsCode()
Convert a custom data array to JavaScript code
protected
getCustomVarsCode(array<string|int, mixed> $customData) : string
Parameters
- $customData : array<string|int, mixed>
-
Custom data
Return values
string —JavaScript Code Fragment
getGenericCustomData()
Get custom data for a generic page view
protected
getGenericCustomData() : array<string|int, mixed>
Return values
array<string|int, mixed> —Associative array of custom data
getInitFunctionName()
Get name of JS init function
protected
getInitFunctionName() : string
Return values
string —getLightboxCustomData()
Get custom data for lightbox actions
protected
getLightboxCustomData() : array<string|int, mixed>
Return values
array<string|int, mixed> —Associative array of custom data
getOpeningTrackingCode()
Get the Initialization Part of the Tracking Code
protected
getOpeningTrackingCode() : string
Return values
string —JavaScript Code Fragment
getPageUrl()
Get the URL for the current page
protected
getPageUrl() : string
Return values
string —getRecordDriver()
Get Record Driver if on a Record Page
protected
getRecordDriver() : AbstractBase|null
Return values
AbstractBase|null —Record driver or null if not on a record page
getRecordPageCustomData()
Get custom data for record page
protected
getRecordPageCustomData(AbstractBase $recordDriver) : array<string|int, mixed>
Parameters
- $recordDriver : AbstractBase
-
Record driver
Return values
array<string|int, mixed> —Associative array of custom data
getSearchCustomData()
Get custom data for search results
protected
getSearchCustomData(Results $results) : array<string|int, mixed>
Parameters
- $results : Results
-
Search results
Return values
array<string|int, mixed> —Associative array of custom data
getSearchResults()
Get Search Results if on a Results Page
protected
getSearchResults() : Results|null
Return values
Results|null —Search results or null if not on a search page
getTrackCombinedSearchCode()
Get site search tracking code for combined search
protected
getTrackCombinedSearchCode(Results $results, array<string|int, mixed> $combinedResults, array<string|int, mixed> $customData) : string
Parameters
- $results : Results
-
Search results
- $combinedResults : array<string|int, mixed>
-
Combined search results
- $customData : array<string|int, mixed>
-
Custom data
Return values
string —JavaScript Code Fragment
getTrackerJsUrl()
Get Matomo tracker JS URL
protected
getTrackerJsUrl() : string
Return values
string —getTrackerUrl()
Get Matomo tracker URL
protected
getTrackerUrl() : string
Return values
string —getTrackPageViewCode()
Get Page View Tracking Code
protected
getTrackPageViewCode(array<string|int, mixed> $customData) : string
Parameters
- $customData : array<string|int, mixed>
-
Custom data
Return values
string —JavaScript Code Fragment
getTrackSearchCode()
Get Site Search Tracking Code
protected
getTrackSearchCode(Results $results, array<string|int, mixed> $customData) : string
Parameters
- $results : Results
-
Search results
- $customData : array<string|int, mixed>
-
Custom data
Return values
string —JavaScript Code Fragment
trackCombinedSearch()
Track a Combined Search
protected
trackCombinedSearch(Results $results, array<string|int, mixed> $combinedResults) : string
Parameters
- $results : Results
-
Search Results
- $combinedResults : array<string|int, mixed>
-
Combined Search Results
Return values
string —Tracking Code
trackPageView()
Track a Generic Page View
protected
trackPageView() : string
Return values
string —Tracking Code
trackRecordPage()
Track a Record View
protected
trackRecordPage(AbstractBase $recordDriver) : string
Parameters
- $recordDriver : AbstractBase
-
Record Driver
Return values
string —Tracking Code
trackSearch()
Track a Search
protected
trackSearch(Results $results) : string
Parameters
- $results : Results
-
Search Results
Return values
string —Tracking Code