// 16 bits, 8 bits for "clk_seq_hi_res",. // 8 bits for "clk_seq_low",. // two most significant bits holds zero and one for variant DCE1.1. wp_rand( 0, 0x3fff ) | 0x8000, // 48 bits for "node". wp_rand( 0, 0xffff ), wp_rand( 0, 0xffff ), wp_rand( 0, 0xffff ) ); } return $this->client_id; } /** * Check if the specified UUID is valid. * * @link http://php.net/preg_match * * @param string $uuid String. * @return boolean True if value is a valid UUID, false otherwise. */ public static function is_uuid( $uuid ) { $result = preg_match( '#^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$#i', $uuid ); return 1 === $result; } /** * Get cookie client ID. * * @return string|null */ public static function get_cookie_client_id() { $client_id = null; $ga_cookie = filter_input( INPUT_COOKIE, '_ga', FILTER_SANITIZE_STRING ); if ( empty( $ga_cookie ) ) { // No `_ga` cookie available. return $client_id; } $ga = explode( '.', $ga_cookie ); if ( isset( $ga[2] ) && self::is_uuid( $ga[2] ) ) { // Use UUID from cookie. $client_id = $ga[2]; } elseif ( isset( $ga[2], $ga[3] ) ) { // Older Google Client ID. $client_id = sprintf( '%s.%s', $ga[2], $ga[3] ); } return $client_id; } /** * Payment redirect URL. * * @param string $url Redirect URL. * @param Payment $payment Payment. * @return string */ public function payment_redirect_url( $url, Payment $payment ) { /** * Payment Gateway Referral Exclusions in Google Analytics. * * @link https://lmgtfy.com/?q=google+analytics+exclude+payment+providers * @link https://webvalue.nl/blog/betaalproviders-uitsluiten-google-analytics * @link https://seeders.nl/lijst-nederlandse-paymentproviders-om-sluiten-google-analytics/ * @link http://blog.analytics-toolkit.com/2015/payment-gateway-referrer-exclusions-google-analytics/ * @link https://andrescholten.nl/a-bank-ideal-ogone-paypal-or-other-payment-providers-getting-all-revenue-in-google-analytics/ * @link https://nicksnell.dev/log/2017/06/exclude-social-login-referrals/ * @link https://bluegg.co.uk/blog/tracking-referrals-when-using-an-external-payment-gatewa * @link https://github.com/Adyen/adyen-magento2/search?q=utm_nooverride */ $url = \add_query_arg( 'utm_nooverride', '1', $url ); return $url; } }