add_event( $event );
return true;
}
/**
* Add a Tracks event to the queue.
*
* @param KKART_Tracks_Event $event Event to track.
*/
public function add_event( $event ) {
$this->events[] = $event;
}
/**
* Add events as tracking pixels to page footer.
*/
public function render_tracking_pixels() {
if ( empty( $this->events ) ) {
return;
}
foreach ( $this->events as $event ) {
$pixel = $event->build_pixel_url();
if ( ! $pixel ) {
continue;
}
echo '';
}
$this->events = array();
}
/**
* Fire off API calls for events that weren't converted to pixels.
*
* This handles wp_redirect().
*/
public function send_tracks_requests() {
if ( empty( $this->events ) ) {
return;
}
foreach ( $this->events as $event ) {
KKART_Tracks_Client::record_event( $event );
}
}
}