Exemplo n.º 1
0
def get_merchant_db_data(store, numdays):
    start, end = get_sliding_date_range(numdays)
    merchant_report = MerchantDbReport(store, ["marketingSource","keyword"],
                                           ["revenue", "order_count"], ["add", "add"], None, time_aggregation=None)
    merchant_data = merchant_report.get_data(mode=None, length=None, start_date=start, end_date=end)

    entries = merchant_data["entries"]

    #vurve_sales = filter(lambda x: x["dimensions"]["marketingSource"]["value"] == "Vurve", entries)
    #nonvurve_sales = filter(lambda x: x["dimensions"]["marketingSource"]["value"] != "Vurve", entries)

    keyword_rev_data = nested_dict()

    for e in entries:
        for kw in e['dimensions']['keyword']['value']:
            keyword_rev_data[kw.lower()]['marketingSource'] = e["dimensions"]["marketingSource"]["value"]
            keyword_rev_data[kw.lower()]['revenue'] = e["metrics"]["revenue"]["value"]
            keyword_rev_data[kw.lower()]['order_count'] = e["metrics"]["order_count"]["value"]

    """
    for entry in vurve_sales:
        for kw in entry["dimensions"]["keyword"]["value"]:
            keyword_rev_data[kw.lower()]["vurve"] = entry["metrics"]["revenue"]["value"]

    for entry in nonvurve_sales:
        for kw in entry["dimensions"]["keyword"]["value"]:
            keyword_rev_data[kw.lower()]["nonvurve"] = entry["metrics"]["revenue"]["value"]
    """

    return keyword_rev_data
Exemplo n.º 2
0
def get_adwords_data(store, numdays):
    start, end = get_sliding_date_range(numdays)

    adwords_report = AdwordsReport(store, ["kwSite"],
                                           ["cost", "qualityScore"], ["add", "average"], None, time_aggregation=None)
    report = adwords_report.get_data(mode=None, length=None, start_date=start, end_date=end)
    spend_data = nested_dict()
    for entry in report["entries"]:
        kw = entry["dimensions"]["kwSite"]["value"].lower()
        spend_data[kw]['cost'] = entry["metrics"]["cost"]["value"]
        spend_data[kw]['quality'] = entry["metrics"]["qualityScore"]["value"]
    return spend_data
Exemplo n.º 3
0
def get_time_on_site_data(store, numdays):
    pixeldb_report = PixelDbReport(store, ["mkg_id","visitor"], ["time_spent"],["add"], None, None)
    start, end = get_sliding_date_range(numdays)
    data = pixeldb_report.get_data(None, None, start, end)

    kw_avg_time_spent = {}
    for e in data["entries"]:
        if e['dimensions']['mkg_id']['value'] is not None:
            kw = e['dimensions']['mkg_id']['value'].lower()
            if kw not in kw_avg_time_spent:
                kw_avg_time_spent[kw] = []
            kw_avg_time_spent[kw].append(e['metrics']['time_spent']['value'])

    return kw_avg_time_spent