Exemplo n.º 1
0
def traffic_this_week(request, project_id):
    end = dt.today()
    start = end - datetime.timedelta(days=7)
    settings = helper.get_settings_by_project_id(project_id)
    count = ga_man.get_session_count(settings.ga_view, ga_man.google_date(start), ga_man.google_date(end))
    data = {"traffic": count}
    return HttpResponse(json.dumps(data), content_type="application/json")
Exemplo n.º 2
0
def conversions_daily(request, project_id):
    drange = util.get_reporting_dates(request)
    start = drange["start"]
    end = drange["end"]
    settings = helper.get_settings_by_project_id(project_id)
    data = {"conversions": ga_man.get_daily_conversions_for_goal(settings.ga_view, settings.goal_to_track, start, end)}
    return HttpResponse(json.dumps(data), content_type="application/json")
Exemplo n.º 3
0
def traffic(request, project_id):
    drange = util.get_reporting_dates(request)
    start = drange["start"]
    end = drange["end"]
    settings = helper.get_settings_by_project_id(project_id)
    count = ga_man.get_session_count(settings.ga_view, ga_man.google_date(start), ga_man.google_date(end))
    data = {"traffic": count}
    return HttpResponse(json.dumps(data), content_type="application/json")
Exemplo n.º 4
0
def top_pages(request, project_id):
    drange = util.get_reporting_dates(request)
    start = drange["start"]
    end = drange["end"]
    settings = helper.get_settings_by_project_id(project_id)
    response = ga_man.get_top_pages(settings.ga_view, start, end)
    data = {"pages": response}
    return HttpResponse(json.dumps(data), content_type="application/json")
Exemplo n.º 5
0
def conversions_total(request, project_id):
    """
    For AJAX-ing purpose
    """
    settings = helper.get_settings_by_project_id(project_id)
    if not request.GET.get("goalId"):
        data = {"conversions": ga_man.get_total_conversion_count(settings)}
    else:
        goalid = request.GET.get("goalId")
        drange = util.get_reporting_dates(request)
        start = drange["start"]
        end = drange["end"]
        data = {"conversions": ga_man.get_conversion_count_for_goal(settings.ga_view, goalid, start, end)}
    return HttpResponse(json.dumps(data), content_type="application/json")