Skip to content

Commit

Permalink
ckan#22 / readme file changes, tracking event function is renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleb committed May 5, 2017
1 parent 7c805cd commit 7d2645a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,19 @@ Features
* Add Google Analytics Event Tracking function that can be used in any exstension
to create your custom events tracking.

``ckanext.googleanalytics.plugin._post_analytics``
``ckanext.googleanalytics.plugin.ga_event_tracking``

function arguments:

- `user`: The user name.

- `event_type`: Custom event type. For example "changed event".

- `request_obj_type`: Custom request object type. For example "Resourse".

- `request_function`: Custom request function. For example "Download".

- `request_id`: Request id, can be dataset ID or resource ID for example.

* Adds Google Analytics Event Tracking to group links on the home page,
user profile links, editing and saving user profiles, etc.
Expand Down
8 changes: 4 additions & 4 deletions ckanext/googleanalytics/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
log = logging.getLogger('ckanext.googleanalytics')


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

"""The function allow to create custom event tracking."""
if config.get('googleanalytics.id'):
data_dict = {
"v": 1,
"tid": config.get('googleanalytics.id'),
"cid": hashlib.md5(c.user).hexdigest(),
"cid": hashlib.md5(user).hexdigest(),
# customer id should be obfuscated
"t": "event",
"dh": c.environ['HTTP_HOST'],
Expand All @@ -46,7 +46,7 @@ def _post_analytics(
def post_analytics_decorator(func):

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

0 comments on commit 7d2645a

Please sign in to comment.