@@ -21,7 +21,7 @@ def get_outbound_links_df(analytics_params, ignore_index=True):
2121 df_builtin_links = get_data_df_from_fields (
2222 [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS ],
2323 [DIMENSION_PAGE_PATH , DIMENSION_BUILTIN_URL , DIMENSION_EVENT_NAME ],
24- dimension_filter = f"eventName=={ EVENT_BUILTIN_CLICK } " ,
24+ dimension_filter = f"eventName=={ EVENT_BUILTIN_CLICK [ 'id' ] } " ,
2525 ** analytics_params ,
2626 ).groupby (
2727 [DIMENSION_PAGE_PATH ["alias" ], DIMENSION_BUILTIN_URL ["alias" ]]
@@ -30,7 +30,7 @@ def get_outbound_links_df(analytics_params, ignore_index=True):
3030 df_custom_links = get_data_df_from_fields (
3131 [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS ],
3232 [DIMENSION_EVENT_NAME , DIMENSION_CUSTOM_URL , DIMENSION_PAGE_PATH ],
33- dimension_filter = f"eventName=={ EVENT_CUSTOM_CLICK } " ,
33+ dimension_filter = f"eventName=={ EVENT_CUSTOM_CLICK [ 'id' ] } " ,
3434 ** analytics_params ,
3535 ).groupby (
3636 [DIMENSION_PAGE_PATH ["alias" ], DIMENSION_CUSTOM_URL ["alias" ]]
@@ -123,7 +123,7 @@ def get_page_views_df(analytics_params, ignore_index=False):
123123 [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS , METRIC_PAGE_VIEWS ],
124124 [DIMENSION_PAGE_PATH , DIMENSION_EVENT_NAME ],
125125 ** analytics_params ,
126- dimension_filter = f"eventName=={ EVENT_PAGE_VIEW } " ,
126+ dimension_filter = f"eventName=={ EVENT_PAGE_VIEW [ 'id' ] } " ,
127127 )[[DIMENSION_PAGE_PATH ["alias" ], METRIC_PAGE_VIEWS ["alias" ], METRIC_TOTAL_USERS ["alias" ]]].copy ()
128128 if not ignore_index :
129129 df_response = df_response .set_index (DIMENSION_PAGE_PATH ["alias" ])
@@ -296,7 +296,7 @@ def get_index_table_download_df(analytics_params, ignore_index=True):
296296 [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS ],
297297 [DIMENSION_ENTITY_NAME , DIMENSION_RELATED_ENTITY_ID , DIMENSION_RELATED_ENTITY_NAME ],
298298 ** analytics_params ,
299- dimension_filter = f"eventName=={ EVENT_FILE_DOWNLOADED } " ,
299+ dimension_filter = f"eventName=={ EVENT_FILE_DOWNLOADED [ 'id' ] } " ,
300300 )
301301 if not ignore_index :
302302 df_response = df_response .set_index ([DIMENSION_ENTITY_NAME ["alias" ], DIMENSION_RELATED_ENTITY_ID ["alias" ], DIMENSION_RELATED_ENTITY_NAME ["alias" ]])
@@ -343,7 +343,7 @@ def get_index_entity_selected_df(analytics_params, ignore_index=True):
343343 [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS ],
344344 [DIMENSION_ENTITY_NAME_TAB ],
345345 ** analytics_params ,
346- dimension_filter = f"eventName=={ EVENT_ENTITY_SELECTED } " ,
346+ dimension_filter = f"eventName=={ EVENT_ENTITY_SELECTED [ 'id' ] } " ,
347347 )
348348 if not ignore_index :
349349 df_response = df_response .set_index ([DIMENSION_ENTITY_NAME_TAB ["alias" ]])
@@ -390,7 +390,7 @@ def get_index_entity_table_sorted_df(analytics_params, ignore_index=True):
390390 [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS ],
391391 [DIMENSION_ENTITY_NAME_TAB , DIMENSION_COLUMN_NAME , DIMENSION_SORT_DIRECTION ],
392392 ** analytics_params ,
393- dimension_filter = f"eventName=={ EVENT_ENTITY_TABLE_SORTED } " ,
393+ dimension_filter = f"eventName=={ EVENT_ENTITY_TABLE_SORTED [ 'id' ] } " ,
394394 )
395395 if not ignore_index :
396396 df_response = df_response .set_index ([DIMENSION_ENTITY_NAME_TAB ["alias" ], DIMENSION_COLUMN_NAME ["alias" ], DIMENSION_SORT_DIRECTION ["alias" ]])
@@ -438,7 +438,7 @@ def get_index_entity_table_paginated_df(analytics_params, ignore_index=True):
438438 [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS ],
439439 [DIMENSION_ENTITY_NAME_TAB , DIMENSION_PAGINATION_DIRECTION ],
440440 ** analytics_params ,
441- dimension_filter = f"eventName=={ EVENT_ENTITY_TABLE_PAGINATED } " ,
441+ dimension_filter = f"eventName=={ EVENT_ENTITY_TABLE_PAGINATED [ 'id' ] } " ,
442442 )
443443 if not ignore_index :
444444 df_response = df_response .set_index ([DIMENSION_ENTITY_NAME_TAB ["alias" ], DIMENSION_PAGINATION_DIRECTION ["alias" ]])
@@ -487,7 +487,7 @@ def get_index_filter_selected_df(analytics_params, ignore_index=True):
487487 [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS ],
488488 [DIMENSION_FILTER_NAME , DIMENSION_FILTER_VALUE ],
489489 ** analytics_params ,
490- dimension_filter = f"eventName=={ EVENT_FILTER_SELECTED } " ,
490+ dimension_filter = f"eventName=={ EVENT_FILTER_SELECTED [ 'id' ] } " ,
491491 )
492492 if not ignore_index :
493493 df_response = df_response .set_index ([DIMENSION_FILTER_NAME ["alias" ], DIMENSION_FILTER_VALUE ["alias" ]])
@@ -519,3 +519,25 @@ def get_index_filter_selected_change(analytics_params, start_current, end_curren
519519 sort_results = [METRIC_EVENT_COUNT , METRIC_TOTAL_USERS ]
520520 )
521521
522+
523+ def get_event_count_over_time_df (analytics_params , events , additional_data_path = None , additional_data_behavior = None ):
524+ """
525+ Get a DataFrame with pageviews and total active users over time from the Analytics API.
526+
527+ :param analytics_params: the parameters for the Analytics API, including service params, start dates, and end dates
528+ :param additional_data_path: the path to a JSON file with additional data to be added to the DataFrame, defaults to None
529+ :param additional_data_behavior: the behavior to use when adding the additional data, as an instance of ADDITIONAL_DATA_BEHAVIOR, defaults to None
530+ :return: a DataFrame with the pageviews and total active users over time from the Analytics API.
531+ Columns are the dimension aliases, metrics (as ints), and change metrics (as floats)
532+ Dimensions: DIMENSION_YEAR_MONTH (as a datetime)
533+ Metrics: METRIC_ACTIVE_USERS, METRIC_PAGE_VIEWS
534+ """
535+
536+ return get_change_over_time_df_multiple_events (
537+ METRIC_EVENT_COUNT ,
538+ events ,
539+ DIMENSION_YEAR_MONTH ,
540+ additional_data_path = additional_data_path ,
541+ additional_data_behavior = additional_data_behavior ,
542+ ** analytics_params
543+ )
0 commit comments