Module: Perfect-GoogleAnalytics-MeasurementProtocol
class PerfectGAEvent
Base type for a Google Analytics Event
func init()
Sets the property ID from the settings
func generate() throws -> String
generates the URL Encoded string for the body of the request
var tid = ""
Tracking ID / Web Property ID
Required for all hit types.
The tracking ID / web property ID. The format is UA-XXXX-Y. All collected data is associated by this ID.
var aip = false
Anonymize IP
Optional.
When present, the IP address of the sender will be anonymized. For example, the IP will be anonymized if any of the following parameters are present in the payload: &aip=, &aip=0, or &aip=1
var ds = "server"
Data Source
Optional.
Indicates the data source of the hit. Hits sent from analytics.js will have data source set to 'web'; hits sent from one of the mobile SDKs will have data source set to 'app'.
var qt = 0
Queue Time
Optional.
Used to collect offline / latent hits. The value represents the time delta (in milliseconds) between when the hit being reported occurred and the time the hit was sent. The value must be greater than or equal to 0. Values greater than four hours may lead to hits not being processed.
var user: UserData = UserData()
The User section of the event
var session: SessionData = SessionData()
The Session section of the event
var traffic: TrafficData = TrafficData()
The Traffic section of the event
var system: SystemData = SystemData()
The System section of the event
var hit: HitData = HitData()
The Hit section of the event
var content: ContentData = ContentData()
The Content section of the event
var appTracking: AppTrackingData = AppTrackingData()
The App Tracking section of the event
var eventTracking: EventTrackingData = EventTrackingData()
The Event Tracking section of the event
var ecomm: EcommData = EcommData()
The Ecommerce section of the event
var social: SocialData = SocialData()
The Social section of the event
var timing: TimingData = TimingData()
The Timing section of the event
var exeption: ExceptionsData = ExceptionsData()
The Exception Handling section of the event
class UserData: generateString
==================== USER ====================
var cid = ""
Client ID
Required for all hit types.
This anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt
var uid = ""
User ID
Optional.
This is intended to be a known identifier for a user provided by the site owner/tracking library user. It must not itself be PII (personally identifiable information). The value should never be persisted in GA cookies or other Analytics provided storage.
class SessionData: generateString
==================== SESSION ====================
var sc: PerfectGAEvent_SessionControl = .none
Session Control
Optional.
Used to control the session duration. A value of 'start' forces a new session to start with this hit and 'end' forces the current session to end with this hit. All other values are ignored.
var uip = ""
IP Override
Optional.
The IP address of the user. This should be a valid IP address in IPv4 or IPv6 format. It will always be anonymized just as though &aip (anonymize IP) had been used.
var ua = ""
User Agent Override
Optional.
The User Agent of the browser. Note that Google has libraries to identify real user agents. Hand crafting your own agent could break at any time.
var geoid = ""
Geographical Override
Optional.
The geographical location of the user. The geographical ID should be a two letter country code or a criteria ID representing a city or region (see http://developers.google.com/analytics/devguides/collection/protocol/v1/geoid). This parameter takes precedent over any location derived from IP address, including the IP Override parameter. An invalid code will result in geographical dimensions to be set to '(not set)'.
class TrafficData: generateString
==================== TRAFFIC SOURCES ====================
var dr = ""
Document Referrer
Optional.
Specifies which referral source brought traffic to a website. This value is also used to compute the traffic source. The format of this value is a URL.
var cn = ""
Campaign Name
Optional.
Specifies the campaign name.
var cs = ""
Campaign Source
Optional.
Specifies the campaign source.
var cm = ""
Campaign Medium
Optional.
Specifies the campaign medium.
var ck = ""
Campaign Keyword
Optional.
Specifies the campaign keyword.
var cc = ""
Campaign Content
Optional.
Specifies the campaign content.
var ci = ""
Campaign ID
Optional.
Specifies the campaign ID.
var gclid = ""
Google AdWords ID
Optional.
Specifies the Google AdWords Id.
var dclid = ""
Google Display Ads ID
Optional.
Specifies the Google Display Ads Id.
class SystemData: generateString
==================== SYSTEM INFO ====================
var sr = ""
Screen Resolution
Optional.
Specifies the screen resolution.
var vp = ""
Viewport size
Optional.
Specifies the viewable area of the browser / device.
var de = ""
Document Encoding
Optional.
Specifies the character set used to encode the page / document.
var sd = ""
Screen Colors
Optional.
Specifies the screen color depth.
var ul = ""
User Language
Optional.
Specifies the language.
var je = ""
Java Enabled
Optional.
Specifies whether Java was enabled.
var fl = ""
Flash Version
Optional.
Specifies the flash version.
class HitData: generateString
==================== HIT ====================
var t: PerfectGAEvent_HitType = .pageview
Hit type
Required for all hit types.
The type of hit. Must be one of 'pageview', 'screenview', 'event', 'transaction', 'item', 'social', 'exception', 'timing'.
var ni = 0
Non-Interaction Hit
Optional. (Boolean, 0 or 1)
Specifies that a hit be considered non-interactive.
class ContentData: generateString
==================== CONTENT INFORMATION ====================
var dl = ""
Document location URL
Optional.
Use this parameter to send the full URL (document location) of the page on which content resides. You can use the &dh and &dp parameters to override the hostname and path + query portions of the document location, accordingly. The JavaScript clients determine this parameter using the concatenation of the document.location.origin + document.location.pathname + document.location.search browser parameters. Be sure to remove any user authentication or other private information from the URL if present. For 'pageview' hits, either &dl or both &dh and &dp have to be specified for the hit to be valid.
var dh = ""
Document Host Name
Optional.
Specifies the hostname from which content was hosted.
var dp = ""
Document Path
Optional.
The path portion of the page URL. Should begin with '/'. For 'pageview' hits, either &dl or both &dh and &dp have to be specified for the hit to be valid.
var dt = ""
Document Title
Optional.
The title of the page / document.
var cd = ""
Screen Name
Required for screenview hit type.
This parameter is optional on web properties, and required on mobile properties for screenview hits, where it is used for the 'Screen Name' of the screenview hit. On web properties this will default to the unique URL of the page by either using the &dl parameter as-is or assembling it from &dh and &dp.
var cg1 = ""
Content Group
Optional.
Each content group has an associated index. There is a maximum of 10 contents groups. The group index must be a positive integer between 1 and 10, inclusive. The value of a content group is heirarchichal text delimited by '/" All leading and trailing slashes will be removed and any repeated slashes will be reduced to a single slash. For example, '/a//b/' will be converted to 'a/b'.
var linkid = ""
Link ID
Optional.
The ID of a clicked DOM element, used to disambiguate multiple links to the same URL in In-Page Analytics reports when Enhanced Link Attribution is enabled for the property.
class AppTrackingData: generateString
==================== APP TRACKING ====================
var an = ""
Application Name
Optional.
Specifies the application name. This field is required for any hit that has app related data (i.e., app version, app ID, or app installer ID). For hits sent to web properties, this field is optional.
var aid = ""
Application ID
Optional.
Application identifier.
var av = ""
Application Version
Optional.
Specifies the application version.
var aiid = ""
Application Installer ID
Optional.
Application installer identifier.
class EventTrackingData: generateString
==================== EVENT TRACKING ====================
var ec = ""
Event Category
Required for event hit type.
Specifies the event category. Must not be empty.
var ea = ""
Event Action
Required for event hit type.
Specifies the event action. Must not be empty.
var el = ""
Event Label
Optional.
Specifies the event label.
var ev = ""
Event Value
Optional.
Specifies the event value. Values must be non-negative.
class EcommData: generateString
==================== E-COMMERCE ====================
var ti = ""
Transaction ID
Required for transaction hit type.
Required for item hit type.
A unique identifier for the transaction. This value should be the same for both the Transaction hit and Items hits associated to the particular transaction.
var ta = ""
Transaction Affiliation
Optional.
Specifies the affiliation or store name.
var tr = ""
Transaction Revenue
Optional.
Specifies the total revenue associated with the transaction. This value should include any shipping or tax costs.
var ts = ""
Transaction Shipping
Optional.
Specifies the total shipping cost of the transaction.
var tt = ""
Transaction Tax
Optional.
Specifies the total tax of the transaction.
var IN = ""
Item Name
Required for item hit type.
Specifies the item name.
NOTE: The specification is uppercase to avoid conflict with Swift syntax.
var ip = ""
Item Price
Optional.
Specifies the price for a single item / unit.
var iq = ""
Item Quantity
Optional.
Specifies the number of items purchased.
var ic = ""
Item Code
Optional.
Specifies the SKU or item code.
var iv = ""
Item Category
Optional.
Specifies the category that the item belongs to.
class SocialData: generateString
==================== SOCIAL INTERACTIONS ====================
var sn = ""
Social Network
Required for social hit type.
Specifies the social network, for example Facebook or Google Plus.
var like = ""
Social Action
Required for social hit type.
Specifies the social interaction action. For example on Google Plus when a user clicks the +1 button, the social action is 'plus'.
var st = ""
Social Action Target
Required for social hit type.
Specifies the target of a social interaction. This value is typically a URL but can be any text.
class TimingData: generateString
==================== TIMING ====================
var utc = ""
User timing category
Required for timing hit type.
Specifies the user timing category.
var utv = ""
User timing variable name
Required for timing hit type.
Specifies the user timing variable.
var utt = ""
User timing time
Required for timing hit type.
Specifies the user timing value. The value is in milliseconds.
var utl = ""
User timing label
Optional.
Specifies the user timing label.
var plt = ""
Page Load Time
Optional.
Specifies the time it took for a page to load. The value is in milliseconds.
var dns = ""
DNS Time
Optional.
Specifies the time it took to do a DNS lookup.The value is in milliseconds.
var pdt = ""
Page Download Time
Optional.
Specifies the time it took for the page to be downloaded. The value is in milliseconds.
var rrt = ""
Redirect Response Time
Optional.
Specifies the time it took for any redirects to happen. The value is in milliseconds.
var tcp = ""
TCP Connect Time
Optional.
Specifies the time it took for a TCP connection to be made. The value is in milliseconds.
var srt = ""
Server Response Time
Optional.
Specifies the time it took for the server to respond after the connect time. The value is in milliseconds.
var dit = ""
DOM Interactive Time
Optional.
Specifies the time it took for Document.readyState to be 'interactive'. The value is in milliseconds.
var clt = ""
Content Load Time
Optional.
Specifies the time it took for the DOMContentLoaded Event to fire. The value is in milliseconds
class ExceptionsData: generateString
==================== EXCEPTIONS ====================
var exd = ""
Exception Description
Optional.
Specifies the description of an exception.
var exf = ""
Is Exception Fatal?
Optional. String as Boolean ("0" or "1")
Specifies whether the exception was fatal.
class ContentExperimentData: generateString
==================== CONTENT EXPERIMENTS ====================
var xid = ""
Experiment ID
Optional.
This parameter specifies that this user has been exposed to an experiment with the given ID. It should be sent in conjunction with the Experiment Variant parameter.
var x= ""
Experiment Variant
Optional.
This parameter specifies that this user has been exposed to a particular variation of an experiment. It should be sent in conjunction with the Experiment ID parameter.
class generateString
Generates the String using introspection.
class HTTPHeaderParser
A lightweight HTTP Response Header Parser
transform the header into a dictionary with http status code
func init(header: String)
HTTPHeaderParser default constructor
- header: the HTTP response header string
var variables: [String:String]
HTTP response header information by keywords
var code: Int
The HTTP response code, e.g.,, HTTP/1.1 200 OK -> let code = 200
var status: String
The HTTP response code, e.g.,, HTTP/1.1 200 OK -> let status = "OK"
var version: String
The HTTP response code, e.g.,, HTTP/1.1 200 OK -> let version = "HTTP/1.1"