WC_Tracks_Event::build_pixel_url()

Build a pixel URL that will send a Tracks event when fired.


Description Description

On error, returns an empty string (”).


Return Return

(string) A pixel URL or empty string ('') if there were invalid args.


Top ↑

Source Source

File: includes/tracks/class-wc-tracks-event.php

	public function build_pixel_url() {
		if ( $this->error ) {
			return '';
		}

		$args = get_object_vars( $this );

		// Request Timestamp and URL Terminator must be added just before the HTTP request or not at all.
		unset( $args['_rt'], $args['_'] );

		$validated = self::validate_and_sanitize( $args );

		if ( is_wp_error( $validated ) ) {
			return '';
		}

		return esc_url_raw( WC_Tracks_Client::PIXEL . '?' . http_build_query( $validated ) );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.