-
Notifications
You must be signed in to change notification settings - Fork 91
Google Analytics Guide
Carolyn Au edited this page Sep 30, 2023
·
6 revisions
Data Commons uses Google Analytics to collect anonymous data to understand the website’s performance and continuously improve our website.
Following are the custom events we added to the website. For details, please refer to ga_events.ts.
Place explorer:
Event name | Example event | Triggered |
---|---|---|
place_category_click | { place_category_click_source: “sidebar”, place_category_click: “economics” } | When the category redirect link is clicked on the place explorer page. |
place_chart_click | { place_chart_click: “export” } | When any of the buttons below a place explorer chart is clicked. |
NL Explore pages:
Event name | Event parameters | Triggered |
---|---|---|
explore_search_q | { query: "search query", source: [homepage|explore_landing|explore] } | Triggered when query is submitted in NL search box |
explore_detect_fulfill | { query: "search query", time_ms: } | Triggered when detection results are returned in NL search |
explore_fulfill | { topic: , place: , time_ms: } | Triggered when topic results are returned in NL search |
Tiles:
Event name | Event parameters | Triggered |
---|---|---|
tile_explore_more | { type: ["Timeline Tool"|"Scatter Tool"|"Map Tool"] } | Triggered when "Explore in ..." is clicked on Explore tiles |
tile_event_source | {url: } | Triggered when tile source link is clicked |
tile_download | { type: ["Timeline Tool"|"Scatter Tool"|"Map Tool"] } | Triggered when "download" button is clicked on a tile |
tile_download_image | - | Triggered when "download image" button is clicked on a tile download modal. |
tile_download_csv | - | Triggered when "download CSV" button is clicked on a tile download modal. |
Other tools:
Event name | Example event | Triggered |
---|---|---|
tool_chart_plot | { stat_var: "median individual income", place_dcid: "geoId/06" } | When a tool chart is mounted or updated with different stat vars or places. |
tool_stat_var_click | { stat_var: "median individual income" } | When a stat var is selected in the stat var hierarchy of visualization tools (scatter, map or timelines) or stat var explorer. |
tool_place_add | { place_dcid: "geoId/06" } | When a place is added to the place search bar of visualization tools (scatter, map or timelines). |
tool_stat_var_search_no_result | { search_term: "median income" } | When no result is shown for a search term in the stat var widget. |
tool_chart_option_click | { tool_chart_option: "per capita" } | When a tool chart option is selected or blurred (population filter) or updated (sources) in the visualization tools. |
- Understand the structure of Google Analytics account.
- Set up Analytics for your website.
- Set up data collection.
- Click "Admin".
- In the Property column, check that you have your new Google Analytics 4 property selected, then click "Data Streams", then "Web". Click the data stream.
- Copy the measurement ID and paste it to configmodule.py.
- Check the HTML of your website and make sure that after the
<head>
, there is an Analytics page tag that begins with:<!-- Global Site Tag (gtag.js) - Google Analytics -->
and ending with</script>
. Also, check if the measurement ID is correct.
- Check if Google Analytics starts to collect data.
- Use real-time report. Trigger some events through clicking or viewing. Wait for several seconds and see if there is any data displayed in the real-time report.
Tips for adding custom events:
- Before setting up a new event or a new parameter, take advantage of the default events and parameters: automatically collected events and enhanced measurement events.
- We’d better keep the parameter name consistent when the value range of a new event’s parameter is the same as another event’s parameter. For example, if we have a "file_download" event and a "chart_plot" event. They all need to collect stat vars and place dcids information. We suggest using the same parameter name "stat_var" and "place_dcid" across the events.
- Avoid high-cardinality parameters.
Exploration Reports Set Up
- Create custom dimensions for custom event parameters.
- On the left, click "Configure" > "Custom definitions".
- Click "Create custom dimensions".
- Enter a name and a description. Select a scope for the custom dimension.
- Select an event parameter or user property from the list or enter the name of an event parameter or user property you'll collect in the future.
- Click "save". You will see a value of (not set) for a custom dimension in the first 48 hours.
- Create custom metrics if needed.
- Set up exploration reports.
- Create an exploration: Click + to create a blank exploration, or use a template to get started quickly.
- Add dimensions and metrics to Variables: In Variables, to the right of the DIMENSIONS or METRICS section, click +. Select the items you want from the list, then click "IMPORT".
- Add data to Tab Settings: Double click the dimensions and metrics to apply them to the row or column section.
Tips for setting up exploration reports:
- If you want to create a report for a specific event, always add the event name to the dimensions and filter on it. Parameters or dimensions could be shared by several events, so it is important to filter on the event name to get the correct data.
- It may take 24 to 48 hours to see the data in Google Analytics after creating a new dimension or metric.
- Understand data threshold and limits.