Skip to content

Commit

Permalink
ckan#22 / no interface needed, function _post_analytics modified
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleb committed Mar 27, 2017
1 parent 4ace993 commit e49e8bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Features
* Adds Google Analytics Event Tracking to some API calls so that usage of the
API can be reported on via Google Analytics.

* Add Google Analytics Event Tracking function that can be used in any exstension
to create your custom events tracking.

``ckanext.googleanalytics.plugin._post_analytics``

* Adds Google Analytics Event Tracking to group links on the home page,
user profile links, editing and saving user profiles, etc.

Expand Down
13 changes: 10 additions & 3 deletions ckanext/googleanalytics/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@


def _post_analytics(
user, request_obj_type, request_function, request_id):
user, event_type, request_obj_type, request_function, request_id):

if config.get('googleanalytics.id'):
data_dict = {
"v": 1,
Expand All @@ -35,7 +36,7 @@ def _post_analytics(
"dh": c.environ['HTTP_HOST'],
"dp": c.environ['PATH_INFO'],
"dr": c.environ.get('HTTP_REFERER', ''),
"ec": "CKAN Resource Download Request",
"ec": event_type,
"ea": request_obj_type + request_function,
"el": request_id,
}
Expand All @@ -45,7 +46,13 @@ def _post_analytics(
def post_analytics_decorator(func):

def func_wrapper(cls, id, resource_id, filename):
_post_analytics(c.user, "Resource", "Download", resource_id)
_post_analytics(
c.user,
"CKAN Resource Download Request",
"Resource",
"Download",
resource_id
)

return func(cls, id, resource_id, filename)

Expand Down

0 comments on commit e49e8bb

Please sign in to comment.