WooCommerce Code Reference

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

Methods

build_timestamp()

Create a timestamp representing milliseconds since 1970-01-01

public static build_timestamp() : string
Return values
stringA 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
stringAn anon id for the user

get_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.

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_ErrorTrue 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.

Return values
boolAlways returns true.