{"id":14483319,"url":"https://github.com/ryonlife/py-google-analytics-cookie","last_synced_at":"2025-07-13T10:31:55.603Z","repository":{"id":1137146,"uuid":"1015761","full_name":"ryonlife/py-google-analytics-cookie","owner":"ryonlife","description":"A simple Python class for parsing useful visitor and referral data from a Google Analytics cookie.","archived":false,"fork":false,"pushed_at":"2013-11-13T04:33:33.000Z","size":105,"stargazers_count":29,"open_issues_count":1,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-04T00:05:28.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryonlife.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-10-22T17:32:31.000Z","updated_at":"2020-06-28T01:08:27.000Z","dependencies_parsed_at":"2022-08-16T12:10:51.402Z","dependency_job_id":null,"html_url":"https://github.com/ryonlife/py-google-analytics-cookie","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryonlife%2Fpy-google-analytics-cookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryonlife%2Fpy-google-analytics-cookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryonlife%2Fpy-google-analytics-cookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryonlife%2Fpy-google-analytics-cookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryonlife","download_url":"https://codeload.github.com/ryonlife/py-google-analytics-cookie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225873588,"owners_count":17537659,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-03T00:01:41.680Z","updated_at":"2024-11-22T09:24:20.299Z","avatar_url":"https://github.com/ryonlife.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Py Google Analytics Cookie Parser\n=====================================\n\n[Py Google Analytics Cookie](https://github.com/ryonlife/py-google-analytics-cookie) is a simple class for parsing useful visitor and referral data from a Google Analytics cookie.\n\nUtilize it during your sign up process in order to permanently store informations about where your customers came from, which opens the door for all sorts of useful metrics...\n\nCookie Breakdown\n----------------\n\n[From utma to utmz](http://www.morevisibility.com/analyticsblog/from-__utma-to-__utmz-google-analytics-cookies.html) is a decent blog post that explains, at a high level, the various cookies Google Analytics uses to store data. The two most interesting (at least to me) are the utma and utmz cookies:\n\n* utma is a persistent cookie that tracks the number of visits, and times of the first and last visit\n* utmz keeps track of all the referral information, with useful nuggets like ad campaigns and referring domain or search engine\n\nUsage\n-----\n\nInstantiate an object with two keyword arguments containing the strings contained in the two cookies.\n\nHere's an example that will work on Pylons:\n\n    from path.to.google_analytics_cookie import GoogleAnalyticsCookie\n    utmz = request.cookies['__utmz'] if 'utmz' in request.cookies else None\n    utma = request.cookies['__utma'] if 'utma' in request.cookies else None\n    gac = GoogleAnalyticsCookie(utmz=utmz, utma=utma)\n\nIn Django:\n\n    from path.to.google_analytics_cookie import GoogleAnalyticsCookie\n    utmz = request.COOKIES['__utmz'] if '__utmz' in request.COOKIES else None\n    utma = request.COOKIES['__utma'] if '__utma' in request.COOKIES else None\n    gac = GoogleAnalyticsCookie(utmz=utmz, utma=utma)\n\nYour object will have utma and utmz attributes that are dictionaries with the following keys:\n\n    gac.utma['domain_hash']\n    gac.utma['random_id']\n    gac.utma['first_visit_at']\n    gac.utma['previous_visit_at']\n    gac.utma['current_visit_at']\n    gac.utma['session_counter']\n\n    gac.utmz['domain_hash']\n    gac.utmz['timestamp']\n    gac.utmz['session_counter']\n    gac.utmz['campaign_number']\n    gac.utmz['campaign_data']['source']\n    gac.utmz['campaign_data']['name']\n    gac.utmz['campaign_data']['medium']\n    gac.utmz['campaign_data']['term']\n    gac.utmz['campaign_data']['content']\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryonlife%2Fpy-google-analytics-cookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryonlife%2Fpy-google-analytics-cookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryonlife%2Fpy-google-analytics-cookie/lists"}