WC_Tracks_Client
in package
WC_Tracks_Client class.
Table of Contents
- BROWSER_TYPE = 'php-agent'
- Browser type.
- PIXEL = 'https://pixel.wp.com/t.gif'
- Pixel URL.
- USER_AGENT_SLUG = 'tracks-client'
- User agent.
- build_timestamp() : string
- Create a timestamp representing milliseconds since 1970-01-01
- get_anon_id() : string
- Grabs the user's anon id from cookies, or generates and sets a new one
- get_identity() : array<string|int, mixed>
- Get a user's identity to send to Tracks. If Jetpack exists, default to its implementation.
- init() : void
- Initialize tracks client class
- maybe_set_identity_cookie() : void
- Check if identity cookie is set, if not set it.
- record_event() : bool|WP_Error
- Record a Tracks event
- record_pixel() : bool
- Synchronously request the pixel.
Constants
BROWSER_TYPE
Browser type.
public
mixed
BROWSER_TYPE
= 'php-agent'
PIXEL
Pixel URL.
public
mixed
PIXEL
= 'https://pixel.wp.com/t.gif'
USER_AGENT_SLUG
User agent.
public
mixed
USER_AGENT_SLUG
= 'tracks-client'
Methods
build_timestamp()
Create a timestamp representing milliseconds since 1970-01-01
public
static build_timestamp() : string
Return values
string — A string representing a timestamp.get_anon_id()
Grabs the user's anon id from cookies, or generates and sets a new one
public
static get_anon_id() : string
Return values
string — An anon id for the userget_identity()
Get a user's identity to send to Tracks. If Jetpack exists, default to its implementation.
public
static get_identity(int $user_id) : array<string|int, mixed>
Parameters
- $user_id : int
-
User id.
Return values
array<string|int, mixed> — Identity properties.init()
Initialize tracks client class
public
static init() : void
Return values
void —maybe_set_identity_cookie()
Check if identity cookie is set, if not set it.
public
static maybe_set_identity_cookie() : void
Return values
void —record_event()
Record a Tracks event
public
static record_event(array<string|int, mixed> $event) : bool|WP_Error
Parameters
- $event : array<string|int, mixed>
-
Array of event properties.
Return values
bool|WP_Error — True on success, WP_Error on failure.record_pixel()
Synchronously request the pixel.
public
static record_pixel(string $pixel) : bool
Parameters
- $pixel : string
-
pixel url and query string.