Skip to content

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.

Google Analytics Events

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.

Google Analytics Set Up

Google Analytics Account Set Up

  1. Understand the structure of Google Analytics account.
  2. Set up Analytics for your website.
  3. Set up data collection.
    1. Click "Admin".
    2. 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.
    3. Copy the measurement ID and paste it to configmodule.py.
    4. 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.
  4. Check if Google Analytics starts to collect data.
    1. 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.

Custom Events Set Up

  1. Set up events.
  2. Verify the event in realtime.

Tips for adding custom events:

  1. 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.
  2. 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.
  3. Avoid high-cardinality parameters.
  1. Create custom dimensions for custom event parameters.
    1. On the left, click "Configure" > "Custom definitions".
    2. Click "Create custom dimensions".
    3. Enter a name and a description. Select a scope for the custom dimension.
    4. 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.
    5. Click "save". You will see a value of (not set) for a custom dimension in the first 48 hours.
  2. Create custom metrics if needed.
  3. Set up exploration reports.
    1. Create an exploration: Click + to create a blank exploration, or use a template to get started quickly.
    2. 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".
    3. 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:

  1. 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.
  2. It may take 24 to 48 hours to see the data in Google Analytics after creating a new dimension or metric.
  3. Understand data threshold and limits.