def ga_context(context_func):
def decorator(func):<EOL><INDENT>@wraps(func)<EOL>def wrapper(self, *args, **kwargs):<EOL><INDENT>context = func(self, *args, **kwargs)<EOL>self.request.google_analytics.update(context_func(context))<EOL>return context<EOL><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
A decorator for Cornice views that allows one to set extra parameters
for Google Analytics tracking::
    @ga_context(lambda context: {'dt': context['category'].title, })
    @view_config(route_name='page')
    def view(request):
        return {
            'category': self.workspace.S(Category).filter(title='foo')[0],
        }
:param func context_func:
    A function which takes one argument, a context dictionary made
    available to the template.
:returns:
    A dict containing the extra variables for Google Analytics
    tracking.