@jinja2.contextfunction
@library.global_function
def ga_push_attribute(context):
 request = context.get('request')
 ga_push = context.get('ga_push', [])
 if ((request.GET.get('fpa') == '1') and request.user.is_authenticated()):
  user = request.user
  group_names = user.groups.values_list('name', flat=True)
  if ('Administrators' in group_names):
   ga_push.append(['_setCustomVar', 1, 'User Type', 'Contributor - Admin', 1])
  elif ('Contributors' in group_names):
   ga_push.append(['_setCustomVar', 1, 'User Type', 'Contributor', 1])
  else:
   ga_push.append(['_setCustomVar', 1, 'User Type', 'Registered', 1])
 return jsonlib.dumps(ga_push)

@ jinja2 . contextfunction @ library . global_function def ga_push_attribute ( context ) : request = context . get ( 'request' ) ga_push = context . get ( 'ga_push' , [ ] ) if ( ( request . GET . get ( 'fpa' ) == '1' ) and request . user . is_authenticated ( ) ) : user = request . user group_names = user . groups . values_list ( 'name' , flat = True ) if ( 'Administrators' in group_names ) : ga_push . append ( [ '_setCustomVar' , 1 , 'User Type' , 'Contributor - Admin' , 1 ] ) elif ( 'Contributors' in group_names ) : ga_push . append ( [ '_setCustomVar' , 1 , 'User Type' , 'Contributor' , 1 ] ) else : ga_push . append ( [ '_setCustomVar' , 1 , 'User Type' , 'Registered' , 1 ] ) return jsonlib . dumps ( ga_push )
return the json for the data-ga-push attribute .