Contents:

class pyga.entities.Campaign(typ)

A representation of Campaign

Properties: _type – See TYPE_* constants, will be mapped to “__utmz” parameter. creation_time – Time of the creation of this campaign, will be mapped to “__utmz” parameter. response_count – Response Count, will be mapped to “__utmz” parameter.

Is also used to determine whether the campaign is new or repeated, which will be mapped to “utmcn” and “utmcr” parameters.
id – Campaign ID, a.k.a. “utm_id” query parameter for ga.js
Will be mapped to “__utmz” parameter.
source – Source, a.k.a. “utm_source” query parameter for ga.js.
Will be mapped to “utmcsr” key in “__utmz” parameter.
g_click_id – Google AdWords Click ID, a.k.a. “gclid” query parameter for ga.js.
Will be mapped to “utmgclid” key in “__utmz” parameter.

d_click_id – DoubleClick (?) Click ID. Will be mapped to “utmdclid” key in “__utmz” parameter. name – Name, a.k.a. “utm_campaign” query parameter for ga.js.

Will be mapped to “utmccn” key in “__utmz” parameter.
medium – Medium, a.k.a. “utm_medium” query parameter for ga.js.
Will be mapped to “utmcmd” key in “__utmz” parameter.
term – Terms/Keywords, a.k.a. “utm_term” query parameter for ga.js.
Will be mapped to “utmctr” key in “__utmz” parameter.
content – Ad Content Description, a.k.a. “utm_content” query parameter for ga.js.
Will be mapped to “utmcct” key in “__utmz” parameter.
class pyga.entities.CustomVariable(index=None, name=None, value=None, scope=3)

Represent a Custom Variable

Properties: index – Is the slot, you have 5 slots name – Name given to custom variable value – Value for the variable scope – Scope can be any one of 1, 2 or 3.

WATCH OUT: It’s a known issue that GA will not decode URL-encoded characters in custom variable names and values properly, so spaces will show up as “%20” in the interface etc. (applicable to name & value) http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=2cdb3ec0be32e078

validate()

According to the GA documentation, there is a limit to the combined size of name and value of 64 bytes after URL encoding, see http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#varTypes and http://xahlee.org/js/google_analytics_tracker_2010-07-01_expanded.js line 563 This limit was increased to 128 bytes BEFORE encoding with the 2012-01 release of ga.js however, see http://code.google.com/apis/analytics/community/gajs_changelog.html

class pyga.entities.Event(category=None, action=None, label=None, value=None, noninteraction=False)

Represents an Event http://code.google.com/apis/analytics/docs/tracking/eventTrackerOverview.html

Properties: category – The general event category action – The action for the event label – An optional descriptor for the event value – An optional value associated with the event. You can see your

event values in the Overview, Categories, and Actions reports, where they are listed by event or aggregated across events, depending upon your report view.
noninteraction – By default, event hits will impact a visitor’s bounce rate.
By setting this parameter to true, this event hit will not be used in bounce rate calculations. (default False)
class pyga.entities.Item

Represents an Item in Transaction

Properties: order_id – Order ID, will be mapped to “utmtid” parameter sku – Product Code. This is the sku code for a given product, will be mapped to “utmipc” parameter name – Product Name, will be mapped to “utmipn” parameter variation – Variations on an item, will be mapped to “utmiva” parameter price – Unit Price. Value is set to numbers only, will be mapped to “utmipr” parameter quantity – Unit Quantity, will be mapped to “utmiqt” parameter

class pyga.entities.Page(path)

Contains all parameters needed for tracking a page

Properties: path – Page request URI, will be mapped to “utmp” parameter title – Page title, will be mapped to “utmdt” parameter charset – Charset encoding, will be mapped to “utmcs” parameter referrer – Referer URL, will be mapped to “utmr” parameter load_time – Page load time in milliseconds, will be encoded into “utme” parameter.

class pyga.entities.Session

You should serialize this object and store it in the user session to keep it persistent between requests (similar to the “__umtb” cookie of the GA Javascript client).

Properties: session_id – A unique per-session ID, will be mapped to “utmhid” parameter track_count – The amount of pageviews that were tracked within this session so far,

will be part of the “__utmb” cookie parameter. Will get incremented automatically upon each request

start_time – Timestamp of the start of this new session, will be part of the “__utmb” cookie parameter

extract_from_utmb(utmb)

Will extract information for the “trackCount” and “startTime” properties from the given “__utmb” cookie value.

class pyga.entities.SocialInteraction(action=None, network=None, target=None)

Properties: action – Required. A string representing the social action being tracked,

will be mapped to “utmsa” parameter
network – Required. A string representing the social network being tracked,
will be mapped to “utmsn” parameter

target – Optional. A string representing the URL (or resource) which receives the action.

class pyga.entities.Transaction

Represents parameters for a Transaction call

Properties: order_id – Order ID, will be mapped to “utmtid” parameter affiliation – Affiliation, Will be mapped to “utmtst” parameter total – Total Cost, will be mapped to “utmtto” parameter tax – Tax Cost, will be mapped to “utmttx” parameter shipping – Shipping Cost, values as for unit and price, will be mapped to “utmtsp” parameter city – Billing City, will be mapped to “utmtci” parameter state – Billing Region, will be mapped to “utmtrg” parameter country – Billing Country, will be mapped to “utmtco” parameter items – @entity.Items in a transaction

add_item(item)

item of type entities.Item

class pyga.entities.Visitor

You should serialize this object and store it in the user database to keep it persistent for the same user permanently (similar to the “__umta” cookie of the GA Javascript client).

Properties: unique_id – Unique user ID, will be part of the “__utma” cookie parameter first_visit_time – Time of the very first visit of this user, will be part of the “__utma” cookie parameter previous_visit_time – Time of the previous visit of this user, will be part of the “__utma” cookie parameter current_visit_time – Time of the current visit of this user, will be part of the “__utma” cookie parameter visit_count – Amount of total visits by this user, will be part of the “__utma” cookie parameter ip_address – IP Address of the end user, will be mapped to “utmip” parameter and “X-Forwarded-For” request header user_agent – User agent string of the end user, will be mapped to “User-Agent” request header locale – Locale string (country part optional) will be mapped to “utmul” parameter flash_version – Visitor’s Flash version, will be maped to “utmfl” parameter java_enabled – Visitor’s Java support, will be mapped to “utmje” parameter screen_colour_depth – Visitor’s screen color depth, will be mapped to “utmsc” parameter screen_resolution – Visitor’s screen resolution, will be mapped to “utmsr” parameter

add_session(session)

Updates the “previousVisitTime”, “currentVisitTime” and “visitCount” fields based on the given session object.

extract_from_server_meta(meta)

Will extract information for the “ip_address”, “user_agent” and “locale” properties from the given WSGI REQUEST META variable or equivalent.

extract_from_utma(utma)

Will extract information for the “unique_id”, “first_visit_time”, “previous_visit_time”, “current_visit_time” and “visit_count” properties from the given “__utma” cookie value.

generate_hash()

Generates a hashed value from user-specific properties.

generate_unique_id()

Generates a unique user ID from the current user-specific properties.

Previous topic

Welcome to PYGA’s documentation!

Next topic

<no title>

This Page