Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
.. image:: https://ci.eionet.europa.eu/buildStatus/icon?job=eea/eea.google/develop :target: https://ci.eionet.europa.eu/job/eea/job/eea.google/job/develop/display/redirect :alt: develop .. image:: https://ci.eionet.europa.eu/buildStatus/icon?job=eea/eea.google/master :target: https://ci.eionet.europa.eu/job/eea/job/eea.google/job/master/display/redirect :alt: master
This package contains useful tools for talking with Google Analytics.
.. contents::
AuthSub tokens
_Google Analytics Data Export API
_.Google Analytics reports created this way can be made available via portlets. Right now there is an example under skins folder.
A python package that provides a low level Google Connection and a generic connection error GoogleClientError. To use this connection you'll need an AuthBase authentication token. You can get one by calling Google like:
After you login into your Google Analytics account, you'll be asked to grant access to yourdomain.com to access Analytics statistics. If you do so, Google will redirect your browser to the next link provided, adding a request parameter token=, in our case
http://yourdomain.com/do_something_with_token?token=ADFAFDDKLJH14234__ASDD
As this token was provided in clear to you, it can be used only once to query Google API, that's why you'll need to exchange it for a multi-session one. But this time you can not do it from browser. So here eea.google.api comes in.
from eea.google.api import Connection google = Connection(token='ADFAFDDKLJH14234__ASDD') new_token = google.token2session()
If you provided an invalid token it will quietly fail and return you a None object, else it will return you a multi-session token. Now you are connected with Google, forever :).
With this connection you can check it's status:
google.status (200, 'OK')
Or make a call:
response = google(scope, data, method='GET')
If something doesn't work well this will raise a GoogleClientError, else
it will return a Google Data Feed Response
_
>> google.request(scope, data, method='GET') Google Tool (eea.google.tool) ============================= A CMF portal tool that can be retrieved using CMF method getToolByName: This a simple container for Google connections. It provides a basic browser interface to add and remove connections. >>> from Products.CMFCore.utils import getToolByName >>> tool = getToolByName(portal, 'portal_google') Google Analytics (eea.google.analytics) ======================================= This package provides the browser interface to register with Google Analytics and defines two storage models: Analytics and AnalyticsReport. Also it provides a utility to easily access low level api.Connection and another one to parse Google response XML. Analytics --------- This will store AuthSub token and it's also a container for Analytics Reports. It provides a basic browser interface to get token from Google and to manage reports. Analytics Report ---------------- A Google Analytics custom report by dimensions, metrics, start-date, end-date, filters and sort order. It is actually a query object for Google Analytics API. >>> from zope.component import getMultiAdapter >>> report = tool.analytics.report >>> xml = getMultiAdapter((report, request), 'index.xml') Now you have a custom XML report based on defined filters. Connection Utility ------------------ Easily access low level eea.google.api.Connection using zope components >>> from zope.component import getUtility >>> from eea.google.analytics.interfaces import IGoogleAnalyticsConnection >>> utility = getUtility(IGoogleAnalyticsConnection) >>> conn = utility(token='ABCDEFGH__FAH') XML Parser utility ------------------ Parse Google reponse XML >>> from zope.component import getUtility >>> from eea.google.analytics.interfaces import IXMLParser >>> parse = getUtility(IXMLParser) >>> table = parse(xml) Here table is a (dimensions, metrics) python generator >>> dimensions, metrics = table.next() >>> dimensions {'ga:pagePath': '/some/doc/path', 'ga:browser': 'Firefox'} >>> metrics {'ga:pageviews': u'34235', 'ga:timeOnPage': '2433.0'} Dependencies ============ 1. python2.4+ 2. Plone 2.5.x or Plone 3.x. (optional if you're using only eea.google.api package). Source code =========== Latest source code (Plone 4 compatible): https://github.com/eea/eea.google Plone 2 and 3 compatible: https://github.com/eea/eea.google/tree/plone25 Copyright and license ===================== The Initial Owner of the Original Code is European Environment Agency (EEA). All Rights Reserved. The EEA Google (the Original Code) is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Contributor(s): Alin Voinea (Eau de Web), Antonio De Marinis (European Environment Agency), More details under docs/License.txt Funding ======= EEA_ - European Enviroment Agency (EU) .. _EEA: https://www.eea.europa.eu/ .. _`AuthSub tokens`: http://code.google.com/apis/accounts/docs/AuthSub.html .. _`Google Analytics Data Export API`: http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDataFeed.html .. _`Google Data Feed Response`: http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDataFeed.html#dataResponse Changelog ========= 5.8 - (2019-01-28) ----------------------- * Jenkins: Add sonarqube step [avoinea refs #101552] * Change: updated URLs pointing to eea.europa.eu with https:// [alecghica refs #95849] 5.7 - (2017-12-12) ------------------ * Change: Replace eeacms/zptlint with eeacms/plone-test:4 zptlint [avoinea refs #90415] 5.6 - (2017-11-07) ------------------ * Change: Remove Sphinx generated documentation [petchesi-iulian refs #88212] 5.5 - (2017-05-22) ------------------ * Change: fixed PyLint warnings and errors [valipod refs #84949] 5.4 - (2017-05-15) ------------------ * Change: fixed PyLint warnings and errors [eduard-fironda refs #84949] 5.3 - (2017-04-24) ------------------ * Change: updated package information [eduard-fironda] 5.2 - (2016-05-19) ------------------ * Bug fix: Fix pylint warnings [ichim-david refs #71940] 5.1 - (2015-10-05) ------------------ * Bugfix: set socket timeout to prevent hanging out connection on xmlrpc calling using eventlet [lucas refs #29063] 5.0 - (2015-08-18) ------------------ * Change: Auto-include zcml within plone context in order to make this package work without having to add it within buildout zcml directive. [avoinea] 4.9 - (2015-03-17) ------------------ * Change: Switched to curl in the jenkins build install script [olimpiurob refs #22402] * Change: Changed fetch url for jenkins build install script to the install script from the main EEA CPB repository [olimpiurob refs #22402] 4.8 - (2014-01-22) ------------------ * Feature: adding Sphinx-generated documentation in Page Template format [batradav refs #9502] * Bug fix: removed wrongly added blockquotes within README.rst [ichim-david refs #18064] 4.7 - (2013-10-04) ------------------ * Change: updated zope imports with the versions that require minimum Plone 4.1 for eea.google [ichimdav refs #15651] 4.6 - (2013-06-17) ------------------ * Change: updated link to site setup [ghicale] 4.5 - (2013-02-04) ------------------ * Bug Fix: Fixed to work with the 2.4 API [batradav refs #9551] 4.4 - (2012-07-13) ------------------ * Bug Fix: Fixed i18n missing tags in .pt files [prospchr refs #5160] 4.3 - (2012-06-12) ------------------ * Bug fix: fixed markup of HISTORY.txt file [ciobabog refs #5231] 4.2 - (2012-02-06) ------------------ * No changes 4.0 - (2011-11-07) ------------------ * Cleanup: of pylint, pyflakes warnings [ichimdav #4140, #4141] * Feature: added upgrade steps [voineali #4392] * Feature: Plone 4.x compatible release [ghicaale #4212] 1.2 (2010-02-24) ---------------- * Bug fix: fixed stinky egg [ghicale] 1.1 (2010-02-24) ---------------- * Bug fix: fixed layout in edit mode [voineali #2685] 1.0 (2009-11-09) ---------------- * Initial release [voineali]response.read()
FAQs
This package contains useful tools for talking with Google Analytics
We found that eea.google demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.