Correction for ga event 'value' parameter

This commit is contained in:
Michael Hall 2018-06-22 16:43:31 -04:00
parent 4fdd428f57
commit f4b9118d7b
6 changed files with 7 additions and 7 deletions

View file

@ -55,7 +55,7 @@ def home(request, *args, **kwards):
city = City.objects.get(id=request.GET.get("city"))
context['city'] = city
ll = [city.latitude, city.longitude]
ga.add_event(request, 'homepage_search', category='search', label='city', value=city.short_name)
ga.add_event(request, 'homepage_search', category='search', label=city.short_name)
else :
context['city_search'] = False
try:

View file

@ -147,7 +147,7 @@ def create_event(request, team_id):
new_event.save()
messages.add_message(request, messages.SUCCESS, message=_('Your event has been scheduled! Next, find a place for your event.'))
ga.add_event(request, action='new_event', category='activity', label='event', value=new_event.get_full_url())
ga.add_event(request, action='new_event', category='activity', label=new_event.get_full_url())
return redirect('add-place', new_event.id)
else:

View file

@ -37,7 +37,7 @@ def start_new_team(request, *args, **kwargs):
new_team.owner_profile = request.user.profile
new_team.save()
Member.objects.create(team=new_team, user=request.user.profile, role=Member.ADMIN)
ga.add_event(request, action='new_team', category='growth', label='team', value=new_team.name)
ga.add_event(request, action='new_team', category='growth', label=new_team.name)
return redirect('define-team', team_id=new_team.pk)
else:
context = {

View file

@ -171,7 +171,7 @@ def user_send_confirmation_email(request):
def user_confirm_email(request, confirmation_key):
if request.user.account.confirm_email(confirmation_key):
messages.add_message(request, messages.SUCCESS, message=_('Your email address has been confirmed.'))
ga.add_event(request, action='email_confirmed', category='activity', label='user', value=str(request.user.profile))
ga.add_event(request, action='email_confirmed', category='activity', label=str(request.user.profile))
return redirect('confirm-notifications')
else:

View file

@ -2,7 +2,7 @@
class GAFailure(Exception):
pass
def add_event(request, action, category=None, label=None, value=None, fail_silently=False):
def add_event(request, action, category=None, label=None, value=1, fail_silently=False):
"""
Attempt to add a message to the request using the 'messages' app.
"""

View file

@ -3,7 +3,7 @@ from django.utils.deprecation import MiddlewareMixin
from django.utils.safestring import SafeData, mark_safe
class GAEvent:
def __init__(self, action, category=None, label=None, value=None):
def __init__(self, action, category=None, label=None, value=1):
self.action = action
self.category = category
self.label = label
@ -11,7 +11,7 @@ class GAEvent:
def gtag(self):
return mark_safe(
"gtag('event', '%(action)s', {'event_category' : '%(category)s', 'event_label' : '%(label)s' , 'event_value' : '%(value)s' });" % {
"gtag('event', '%(action)s', {'event_category' : '%(category)s', 'event_label' : '%(label)s' , 'value' : '%(value)s' });" % {
'action': self.action,
'category': self.category,
'label': self.label,