Usage
nebula()->nebula_session_id()
Parameters
This function does not accept any parameters. Is this incorrect?
Additional Notes
t:1502941358;dev:1;r:subscriber;uid:17;s:ffq669njdj9dnmpgcj2de8osp1;cid:1068816418.1487540422;
Default Components
- t – Server-side UTC timestamp of the last pageview in the session.
- d – Debug mode
- p – Prototype mode
- cli – Client user (Matched by IP address or logged-in email domain)
- dev – Developer user (Matched by IP address or logged-in email domain)
- r – Logged-in WordPress user role
- uid – Logged-in WordPress user ID
- bot – Known bot
- l – If the site is not live (using is_site_live()) Note: Only appears if false
- s – Session ID or Unique ID (Note: unique ID is prepended with
!
) - cid – Google Analytics CID
- This is parsed from the Google Analytics cookie (two numbers separated by
.
) or generated by Nebula (four groups of numbers separated by-
) - The first number in the GA cookie is a random ID and the second is a UTC timestamp of the user’s first visit.
- This is an ID tied to the user and can be used to track multiple sessions.
- This is parsed from the Google Analytics cookie (two numbers separated by
Use the filter nebula_session_id
to add more values to this session ID. Remember that this value is accessible in the page source, so data may be seen by the visitor. Important: Do not add personally identifiable information to this session ID! This data is stored in Google Analytics where PII is against the Terms of Service.
Follow the Nebula Recommendations to create custom dimensions including one for Session ID so it can provide context to visitor data in Google Analytics.
Tips
- This information can be sent with all Contact Form 7 forms by including a hidden filed with the class
debuginfo
. - Use these to create a segment within Google Analytics to focus only on important traffic.
- Create temporary segments or report filters to track individual users with their CID.
- On initial visit, Nebula generates a CID which is replaced via JavaScript when an actual Google Analytics Client ID is generated.
- If the Nebula version remains it indicates that Google Analytics or JavaScript is blocked.
Source File
Located in /libs/Utilities/Utilities.php on line 74.
2 Hooks
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"nebula_session_id"Need a new filter hook? Request one here.
Actions
"qm/info"Need a new action hook? Request one here.
public function nebula_session_id(){ $cache_group = uniqid(); //Each "user" gets its own group so it persists without interfering with each other //Check object cache first $session_id = wp_cache_get('nebula_session_id', $cache_group); //If session_id() is not available, it will re-generate the Nebula session ID if ( !empty($session_id) ){ return sanitize_text_field($session_id); } $timer_name = $this->timer('Session ID'); $session_data = array(); //Time $session_data['t'] = time(); //Debug if ( $this->is_debug() ){ $session_data['d'] = true; } //Client/Developer if ( $this->is_client() ){ $session_data['cli'] = true; } if ( $this->is_dev() ){ $session_data['dev'] = true; } //Logged in user role if ( is_user_logged_in() ){ $user_info = get_userdata(get_current_user_id()); $session_data['r'] = 'unknown'; if ( !empty($user_info->roles) ){ $session_data['r'] = $user_info->roles[0]; } $session_data['uid'] = get_current_user_id(); } //Bot detection if ( $this->is_bot() ){ $session_data['bot'] = true; } //Site Live if ( !$this->is_site_live() ){ $session_data['l'] = false; } //Session ID $session_data['s'] = $cache_group; //Use the unique ID that determines the group as the main ID //Google Analytics CID $session_data['cid'] = $this->ga_parse_cookie(); //Additional session information $all_session_data = apply_filters('nebula_session_id', $session_data); //Convert to a string $session_id = ''; foreach ( $all_session_data as $key => $value ){ $session_id .= $key . ':' . $value . ';'; } //do_action('qm/info', 'Nebula Session ID: ' . $session_id); wp_cache_set('nebula_session_id', $session_id, $cache_group); //Store in object cache grouped by the unique ID to prevent interference $this->timer($timer_name, 'end'); return sanitize_text_field($session_id); }
Override
This function can not be short-circuited with an override filter. Request one?