Skip to main content
Release Version
Unleash the power of your behavioral data
If you're looking for a more guided approach that contains information about tracking and modeling your data, check out our Web Performance Accelerator!
๐Ÿ‘‰ Take me there! ๐Ÿ‘ˆ

Core Web Vitals Custom Module

This custom module is built as an extension of the dbt-snowplow-web package, it transforms raw web vitals event data into derived tables for easier querying. These events are generated by the Snowplow Web Vitals plugin (@snowplow/browser-plugin-web-vitals) of the JavaScript tracker.

To enable this optional module, the web package must be correctly configured. Please refer to the quickstart guides for a full breakdown of how to set it up.

Prerequisitesโ€‹

In order to use this module you would need to:

  1. Track core web vitals using the web Snowplow Web Vitals plugin, which populates the column/table unstruct_event_com_snowplowanalytics_snowplow_web_vitals_1
  2. Have the yauaa enrichment enabled (for device type and device class), which populates contexts_nl_basjes_yauaa_context_1
  3. (Ideally, but not necessarily) Have the spiders and bots enrichment enabled, which populates contexts_com_iab_snowplow_spiders_and_robots_1

Overviewโ€‹

This custom module consists of a series of dbt models which produce the following aggregated models from the raw web vitals events:

  • snowplow_web_web_vitals: Incremental table used as a base for storing core web vital events (first event per page view).
  • snowplow_web_web_vital_measurements: Drop and recompute table to use for visualizations that takes core web vital measurements at the user specified percentile point (defaulted to 75).

Operationโ€‹

It is assumed that the Snowplow web package is already installed and configured as per the Quick Start instructions.

Enable the moduleโ€‹

You can enable the custom module through the snowplow__enable_cwv variable in your dbt_project.yml file:

dbt_project.yml

vars:
snowplow_web:
snowplow__enable_cwv: true

Override the module specific macrosโ€‹

tip

For information about overriding our macros, see here

  • The core_web_vital_page_groups() (source) macro is used to let the user classify their urls to specific page groups. It returns the sql to provide the classification (expected in the form of case when statements).

  • The core_web_vital_results_query() (source) macro is used to let the user classify the thresholds to be applied for the measurements. It returns the sql to provide the logic for the evaluation based on user defined thresholds (expected in the form of case when statements).

Please make sure you set the results you would like the measurements to pass to good or align it with the macro_core_web_vital_pass_query() macro.

  • The core_web_vital_pass_query() (source)
case when lcp_result = 'good' and fid_result = 'good' and cls_result = 'good' then 1 else 0 end passed

Run the moduleโ€‹

If you have previously run the model without this optional module enabled, you can simply enable the module and run dbt run --selector snowplow_web as many times as needed for this module to catch up with your other data. If you only wish to process this from a specific date, be sure to change your snowplow__start_date, or refer to the Custom module section for a detailed guide on how to achieve this the most efficient way.

If you haven't run the web package before, then you can run it using dbt run --selector snowplow_web either through your CLI, within dbt Cloud, or for Enterprise customers you can use the BDP console. In this situation, all models will start in-sync as no events have been processed.