def build_parameters(self): params = Parameters() params.utmac = self.tracker.account_id params.utmhn = self.tracker.domain_name params.utmt = self.get_type() params.utmn = utils.get_32bit_random_num() ''' The "utmip" parameter is only relevant if a mobile analytics ID (MO-XXXXXX-X) was given ''' params.utmip = self.visitor.ip_address params.aip = self.tracker.config.anonimize_ip_address and 1 or None # Add override User-Agent parameter (&ua) and override IP address # parameter (&uip). Note that the override IP address parameter is # always anonymized, as if &aip were present (see # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#uip) params.ua = self.visitor.user_agent params.uip = utils.anonymize_ip(self.visitor.ip_address) if params.aip: # If anonimization of ip enabled? then! params.utmip = utils.anonymize_ip(params.utmip) params.utmhid = self.session.session_id params.utms = self.session.track_count params = self.build_visitor_parameters(params) params = self.build_custom_variable_parameters(params) params = self.build_campaign_parameters(params) params = self.build_cookie_parameters(params) return params
def build_parameters(self): params = Parameters() params.utmac = self.tracker.account_id params.utmhn = self.tracker.domain_name params.utmt = self.get_type() params.utmn = utils.get_32bit_random_num() ''' The "utmip" parameter is only relevant if a mobile analytics ID (MO-XXXXXX-X) was given ''' params.utmip = self.visitor.ip_address params.aip = self.tracker.config.anonimize_ip_address and 1 or None if params.aip: # If anonimization of ip enabled? then! params.utmip = utils.anonymize_ip(params.utmip) params.utmhid = self.session.session_id params.utms = self.session.track_count params = self.build_visitor_parameters(params) params = self.build_custom_variable_parameters(params) params = self.build_campaign_parameters(params) params = self.build_cookie_parameters(params) return params
def generate_unique_id(self): '''Generates a unique user ID from the current user-specific properties.''' return ((utils.get_32bit_random_num() ^ self.generate_hash()) & 0x7fffffff)
def generate_session_id(): return utils.get_32bit_random_num()
def __init__(self): self.session_id = utils.get_32bit_random_num() self.track_count = 0 self.start_time = datetime.utcnow()