SessionStats
in package
Table of Contents
Properties
- $do_tracking : mixed
- Should tracking be done? Determined at request start time
- $untracked : mixed
- Prefixes of URLs to ignore
Methods
- disableTracking() : void
- Prevent page-view tracking for the current request.
- init() : mixed
- Check whether this content should be tracked, and enable tracking in this case
- numPageviews() : int
- Return the number of page views for a given url
- referrer() : string
- The initial HTTP referrer when the session was first started
- timeOnSite() : DateInterval
- How long the user has been on the site
- timeStart() : DateTime
- Time the session started
- totalPageviews() : int
- Return the total number of page views
- trackPageView() : mixed
- Track a page view in the session
- uniquePageviews() : int
- Return the total number of unique page views
- utmCampaign() : string
- Value of the 'utm_campaign' query string parameter from the most recent request which contained this parameter
- utmContent() : string
- Value of the 'utm_content' query string parameter from the most recent request which contained this parameter
- utmMedium() : string
- Value of the 'utm_medium' query string parameter from the most recent request which contained this parameter
- utmSource() : string
- Value of the 'utm_source' query string parameter from the most recent request which contained this parameter
- utmTerm() : string
- Value of the 'utm_term' query string parameter from the most recent request which contained this parameter
- trackSession() : mixed
- Session level tracking - utm tags, referrer, etc
- autoDetectSourceMedium() : array<string|int, mixed>
- Auto-generate UTM params based on the initial request referrer
Properties
$do_tracking
Should tracking be done? Determined at request start time
private
static mixed
$do_tracking
= false
$untracked
Prefixes of URLs to ignore
private
static mixed
$untracked
= ['admin', 'dbtools', 'email_share', 'embed_video', 'file', 'page', 'result', 'robots.txt', 'search', 'seo/xmlSitemap', 'tinymce4', 'favicon.ico', '_media', '_errors', '_healthcheck']
Methods
disableTracking()
Prevent page-view tracking for the current request.
public
static disableTracking() : void
init()
Check whether this content should be tracked, and enable tracking in this case
public
static init() : mixed
numPageviews()
Return the number of page views for a given url
public
static numPageviews(string $url) : int
Parameters
- $url : string
-
URL to return stats for; query strings are stripped
Return values
int —Num page views
referrer()
The initial HTTP referrer when the session was first started
public
static referrer() : string
Return values
string —URL
timeOnSite()
How long the user has been on the site
public
static timeOnSite() : DateInterval
Return values
DateIntervaltimeStart()
Time the session started
public
static timeStart() : DateTime
Return values
DateTimetotalPageviews()
Return the total number of page views
public
static totalPageviews() : int
Return values
int —Num page views
trackPageView()
Track a page view in the session
public
static trackPageView() : mixed
uniquePageviews()
Return the total number of unique page views
public
static uniquePageviews() : int
Return values
int —Num page views
utmCampaign()
Value of the 'utm_campaign' query string parameter from the most recent request which contained this parameter
public
static utmCampaign() : string
Return values
string —UTM request campaign, e.g. 'spring_sale'
utmContent()
Value of the 'utm_content' query string parameter from the most recent request which contained this parameter
public
static utmContent() : string
Return values
string —UTM request term, e.g. 'logolink' or 'textlink'
utmMedium()
Value of the 'utm_medium' query string parameter from the most recent request which contained this parameter
public
static utmMedium() : string
Return values
string —UTM request medium, e.g. 'cpc', 'organic', 'social', 'email', etc
utmSource()
Value of the 'utm_source' query string parameter from the most recent request which contained this parameter
public
static utmSource() : string
Return values
string —UTM request source, e.g. 'google', 'bing', 'facebook', etc
utmTerm()
Value of the 'utm_term' query string parameter from the most recent request which contained this parameter
public
static utmTerm() : string
Return values
string —UTM request term, e.g. 'running shoes'
trackSession()
Session level tracking - utm tags, referrer, etc
protected
static trackSession() : mixed
autoDetectSourceMedium()
Auto-generate UTM params based on the initial request referrer
private
static autoDetectSourceMedium(string $referrer) : array<string|int, mixed>
Parameters
- $referrer : string
-
Full URL, e.g. 'https://facebook.com/post/987654321
Return values
array<string|int, mixed> —Two strings or NULL if not known; 0 => source, 1 => medium