def report_definition(self): return ReportDefinition(segments=self.segments, dimensions=self.dimensions, metrics=self.metrics, date_from=self.date_from, date_to=self.date_to, last_days=self.last_days, granularity=self.granularity, source=self.source)
""" Note that a report definition is independent of a Suite. Often you want to download a report for multiple suites. With this helper method first all your reports are requested and then one after another downloaded. This will save you time as you're downloading your first reports already while the bigger ones are still being processed. """ from adobe_analytics import Client, ReportDefinition from adobe_analytics import download_async client = Client.from_json("my_credentials.json") report_definition = ReportDefinition(dimensions="page", metrics="pageviews", date_from="2017-01-01", date_to="2017-12-31") # for maximum speed improvements sort your suite_ids list by expected size of data in response # sort from smallest to largest df = download_async(client, report_definition, suite_ids=["suite_id_1", "suite_id_2"]) print(df.head())
# can be used to return a list of available metrics, dimensions and segments if the code needs to be updated # print(suite.metrics()) # print(suite.dimensions()) # print(suite.segments()) # running report for top 400 dimensions for 2018-09-01 to 2018-09-15 # dimensions - prop45(Device ID), evar131(AB Testing Segment) # metrics - visits, page views, event22(Article View) report_definition = ReportDefinition( dimensions=[ {"id": "prop45", "top": 400}, {"id": "evar131", "top": 1}, ], metrics=[ "visits", "pageviews", "event22", ], date_from="2018-09-01", date_to="2018-09-15", ) # saving output in a dataframe device_df = suite.download(report_definition) # transforming dataframe by converting strings to numeric (where applicable) and dropping na and device id = 000.... device_df = device_df.apply(pd.to_numeric, errors="ignore") device_df = device_df[device_df["Device ID"] != "00000000-0000-0000-0000-000000000000"] device_df = device_df.dropna()
from adobe_analytics import Client, ReportDefinition client = Client.from_json("my_credentials.json") suites = client.suites() suite = suites["my_report_suite_id"] report_definition = ReportDefinition( dimensions=["page", "product", "lasttouchchannel"], metrics=["visits", "orders"], date_from="2017-01-01", date_to="2017-12-31", granularity="day") dataframe = suite.download(report_definition) print(dataframe.head())
from adobe_analytics import Client, ReportDefinition client = Client.from_json("my_credentials.json") suites = client.suites() suite = suites["my_report_suite_id"] # similar to classification reports you need to specify an additional parameter per dimension to receive more than # 10 values. # The 'top' parameter supports values up to 50k. If you need more values, you need to switch to utilize the warehouse report_definition = ReportDefinition( dimensions=[ {"id": "page", "top": 5000} ], metrics="pageviews", date_from="2017-01-01", date_to="2017-12-31" ) dataframe = suite.download(report_definition) print(dataframe.head())
from adobe_analytics import Client, ReportDefinition client = Client.from_json("my_credentials.json") suites = client.suites() suite = suites["my_report_suite_id"] report_definition = ReportDefinition( dimensions="page", metrics="pageviews", date_from="2017-01-01", date_to="2017-12-31", granularity="day" # only change to basic_report.py ) dataframe = suite.download(report_definition) print(dataframe.head())
from adobe_analytics import Client, ReportDefinition client = Client.from_json("my_credentials.json") suites = client.suites() suite = suites["my_report_suite_id"] report_definition = ReportDefinition( dimensions="page", metrics="pageviews", date_from="2017-01-01", date_to="2017-12-31", source="warehouse" # only change to basic_report.py ) dataframe = suite.download(report_definition) print(dataframe.head())
from adobe_analytics import Client, ReportDefinition client = Client.from_json("my_credentials.json") suites = client.suites() suite = suites["my_report_suite_id"] # for classifications a simple string for the dimension_id isn't sufficient anymore # you need to specify the id and the classification name in a dictionary report_definition = ReportDefinition( dimensions=[ {"id": "product", "classification": "Product Name"} ], metrics=["visits", "orders"], # similar for metrics date_from="2017-01-01", date_to="2017-12-31", granularity="day" ) dataframe = suite.download(report_definition) print(dataframe.head())
#Now you know the ID's of dimentions, segments and suites, you can start API call for data by providing different parameters. # download_async method gives us the flexbility to download the same report from multiple report suite at once # top = number of rows to be pulled for specific dimention # You can change how date_from and date_to is called report_def = ReportDefinition( metrics=['visits', 'Orders'], dimensions=[{ "id": "dimention_id", "top": 500 }], segemnts=[{ "id": "segment1-id" }, { "id": "segment2-id" }, { "id": "segment3-id" }, { "id": "segment4-id" }], date_from=str( date(today.year, today.month, today.day) - timedelta(days=1)), date_to=str(date(today.year, today.month, today.day)), granularity='hour') adobe_data = download_async(client, report_def, suite_ids=["suite-1", "suite-2", "suite-3"]) # well done , Now you have a data frame in python with adobe analytics data in it. you can utilize this in multiple ways. #Thank You