Usage
nebula()->utms()
Parameters
This function does not accept any parameters. Is this incorrect?
Examples
Get the landing page URL and UTM parameters of a subsequent pageview
var_dump(nebula()->utms());
Get the original landing page URL and UTM parameters on a subsequent pageview in JavaScript
console.log(nebula.session.utms);
Read it directly from the cookie in PHP
var_dump($_COOKIE['nebula_utms']);
Read it directly from the cookie in JavaScript
console.log(nebula.readCookie('nebula_utms'));
Additional Notes
Important: This function requires the “Attribution Tracking” Nebula Option to be enabled in order to use it! Be sure that the use of this cookie fits within your privacy policy and other regulations.
Note that this stores the entire URL of the landing page (LP) including the entire query string if any UTM tag (or other tracking parameter) exists.
Source File
Located in /libs/Utilities/Utilities.php on line 686.
No Hooks
This function does not have any filters or actions available. Request one?Note: This function contains 1 to-do comment.
public function utms(){ if ( !$this->is_analytics_allowed() ){ //Do nothing if analytics is not allowed return ''; } if ( $this->get_option('attribution_tracking') ){ //This functionality requires the Attribution Tracking Nebula Option because it adds tracking cookies //Check the cookie first if ( !empty($this->super->cookie['nebula_utms']) ){ return sanitize_text_field(htmlspecialchars($this->super->cookie['nebula_utms'])); } //Otherwise check for various UTM parameters $notable_tags = array('utm_', 'fbclid', 'gclid', 'gclsrc', 'dclid', 'gbraid', 'wbraid', 'mc_eid', '_hsenc', 'vero_id', 'mkt_tok'); $urls_to_check = array( $this->url_components('query'), //Check the URL of the current page request ); //Check the referer header URL too (if it exists) //Note: This will only be used if a UTM value is not found in the current page request if ( !empty($this->super->server['HTTP_REFERER']) ){ if ( $this->url_components('domain', $this->super->server['HTTP_REFERER']) == $this->url_components('domain') ){ //Only if the referrer also matches the current website domain. Using "domain" instead of "hostname" to allow UTM parameters to be read from subdomains too. $urls_to_check[] = $this->url_components('query', $this->super->server['HTTP_REFERER']); } } foreach ( $urls_to_check as $query_string ){ //Loop through the URLs that may contain UTM tags foreach ( $notable_tags as $tag ){ //Loop through each of the notable tracking tags if ( strpos(strtolower($query_string), $tag) > -1 ){ //If UTM parameters exist //@todo "Nebula" 0: Update strpos() to str_contains() in PHP8 $this->set_cookie('nebula_utms', $this->url_components('all'), strtotime('+14 months')); //Set/update the cookie and store the entire LP URL return sanitize_text_field($this->url_components('all')); //Return the entire landing page URL with full query string sanitized } } } } return ''; }
Override
This function can not be short-circuited with an override filter. Request one?