Skip to main content

Snowplow Web Macros

caution

This page is auto-generated from our dbt packages, some information may be incomplete

Snowplow Webโ€‹

Allow Refreshโ€‹

macros/allow_refresh.sql

Description

This macro is used to determine if a full-refresh is allowed (depending on the environment), using the snowplow__allow_refresh variable.

Returns

snowplow__allow_refresh if environment is not dev, none otherwise.

Details

Code
Source
{% macro allow_refresh() %}
{{ return(adapter.dispatch('allow_refresh', 'snowplow_web')()) }}
{% endmacro %}

Depends On

Referenced By

Channel Group Queryโ€‹

macros/channel_group_query.sql

Description

This macro returns the sql to identify the marketing channel from a url based on the mkt_source, mkt_medium, and mkt_campaign fields. It can be overwritten to use a different logic.

Returns

The sql to provide the classification (expected in the form of case when statements).

Details

Code
Source
{% macro channel_group_query() %}
{{ return(adapter.dispatch('channel_group_query', 'snowplow_web')()) }}
{% endmacro %}

Referenced By

Consent Fieldsโ€‹

macros/bigquery/consent_fields.sql

Description

This macro does not currently have a description.

Details

Code
Source
{% macro consent_fields() %}

{% set consent_fields = [
{'field': 'event_type', 'dtype': 'string'},
{'field': 'basis_for_processing', 'dtype': 'string'},
{'field': 'consent_url', 'dtype': 'string'},
{'field': 'consent_version', 'dtype': 'string'},
{'field': 'consent_scopes', 'dtype': 'string'},
{'field': 'domains_applied', 'dtype': 'string'},
{'field': 'gdpr_applies', 'dtype': 'string'}
] %}

{{ return(consent_fields) }}

{% endmacro %}

Referenced By

Content Group Queryโ€‹

macros/content_group_query.sql

Description

This macro does not currently have a description.

Details

Code
Source
{% macro content_group_query() %}
{{ return(adapter.dispatch('content_group_query', 'snowplow_web')()) }}
{% endmacro %}

Referenced By

Core Web Vital Page Groupsโ€‹

macros/core_web_vital_page_groups.sql

Description

This macro is used to let the user classify page urls into page groups.

Returns

The sql to provide the classification (expected in the form of case when statements).

Details

Code
Source
{% macro core_web_vital_page_groups() %}
{{ return(adapter.dispatch('core_web_vital_page_groups', 'snowplow_web')()) }}
{%- endmacro -%}


Referenced By

Core Web Vital Pass Queryโ€‹

macros/core_web_vital_pass_query.sql

Description

This macro is used to let the user define what counts as the overall pass condition for the core web vital measurements.

Returns

The sql to provide the logic for the evaluation based on user defined tresholds (expected in the form of case when statements).

Details

Code
Source
{% macro core_web_vital_pass_query() %}
{{ return(adapter.dispatch('core_web_vital_pass_query', 'snowplow_web')()) }}
{%- endmacro -%}


Referenced By

Core Web Vital Results Queryโ€‹

macros/core_web_vital_results_query.sql

Description

This macro is used to let the user classify the tresholds to be applied for the measurements. 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.

Returns

The sql to provide the logic for the evaluation based on user defined tresholds (expected in the form of case when statements).

Details

Code
Source
{% macro core_web_vital_results_query(suffix) %}
{{ return(adapter.dispatch('core_web_vital_results_query', 'snowplow_web')(suffix)) }}
{%- endmacro -%}


Referenced By

Engaged Sessionโ€‹

macros/engaged_session.sql

Description

This macro returns the sql to identify if a session is classed as engaged or not. It can be overwritten to use a different logic. By default any session that has 2 or more page views, more than 2 heartbeats worth of engaged time, or has any conversion events is classed as engaged.

Note that if you are overwriting this macro you have may not have immediate access to all fields in the derived sessions table, and may have to use a table alias to specify the column you wish to use, please see the definition of snowplow_web_sessions_this_run to identify which fields are available at the time of the macro call.

Returns

The sql defining an engaged session (true/false).

Details

Code
Source
{% macro engaged_session() %}
{{ return(adapter.dispatch('engaged_session', 'snowplow_web')()) }}
{% endmacro %}

Referenced By

Filter Botsโ€‹

macros/filter_bots.sql

Description

This macro is used to generate a warehouse specific filter for the useragent field to remove bots from processing, or to overwrite for custom filtering. The filter excludes any of the following in the string:

  • bot
  • crawl
  • slurp
  • spider
  • archiv
  • spinn
  • sniff
  • seo
  • audit
  • survey
  • pingdom
  • worm
  • capture
  • (browser|screen)shots
  • analyz
  • index
  • thumb
  • check
  • facebook
  • PingdomBot
  • PhantomJS
  • YandexBot
  • Twitterbot
  • a_archiver
  • facebookexternalhit
  • Bingbot
  • BingPreview
  • Googlebot
  • Baiduspider
  • 360(Spider|User-agent)
  • semalt

Arguments

  • table_alias (string): (Optional) the table alias to identify the useragent column from. Default none

Returns

A filter on useragent to exclude those with strings matching the above list.

Usage

select
...
from
...
where 1=1
filter_bots()

-- returns (snowflake)
select
...
from
...
where 1=1
and not rlike(useragent, '.*(bot|crawl|slurp|spider|archiv|spinn|sniff|seo|audit|survey|pingdom|worm|capture|(browser|screen)shots|analyz|index|thumb|check|facebook|PingdomBot|PhantomJS|YandexBot|Twitterbot|a_archiver|facebookexternalhit|Bingbot|BingPreview|Googlebot|Baiduspider|360(Spider|User-agent)|semalt).*')

Details

Code
Source
{% macro filter_bots(table_alias = none) %}
{{ return(adapter.dispatch('filter_bots', 'snowplow_web')(table_alias)) }}
{%- endmacro -%}


Referenced By

Get Conversion Columnsโ€‹

macros/get_conversion_columns.sql

Description

This macro does not currently have a description.

Details

Code
Source
{% macro get_conversion_columns(conv_object = {}, names_only = false) %}
{{ return(adapter.dispatch('get_conversion_columns', 'snowplow_web')(conv_object, names_only)) }}
{% endmacro %}

Depends On

  • macro.dbt.type_boolean

Referenced By

Get Iab Context Fieldsโ€‹

macros/get_context_fields.sql

Description

This macro is used to extract the fields from the iab enrichment context for each warehouse.

Arguments

  • table_prefix (string): (Optional) Table alias to prefix the column selection with. Default none

Returns

The sql to extract the columns from the iab context, or these columns as nulls.

Details

Code
Source
{% macro get_iab_context_fields(table_prefix = none) %}
{{ return(adapter.dispatch('get_iab_context_fields', 'snowplow_web')(table_prefix)) }}
{%- endmacro -%}


Depends On

Referenced By

Get Ua Context Fieldsโ€‹

macros/get_context_fields.sql

Description

This macro is used to extract the fields from the ua enrichment context for each warehouse.

Arguments

  • table_prefix (string): (Optional) Table alias to prefix the column selection with. Default none

Returns

The sql to extract the columns from the ua context, or these columns as nulls.

Details

Code
Source
{% macro get_ua_context_fields(table_prefix = none) %}
{{ return(adapter.dispatch('get_ua_context_fields', 'snowplow_web')(table_prefix)) }}
{%- endmacro -%}


Depends On

Referenced By

Get Yauaa Context Fieldsโ€‹

macros/get_context_fields.sql

Description

This macro is used to extract the fields from the yauaa enrichment context for each warehouse.

Arguments

  • table_prefix (string): (Optional) Table alias to prefix the column selection with. Default none

Returns

The sql to extract the columns from the yauaa context, or these columns as nulls.

Details

Code
Source
{% macro get_yauaa_context_fields(table_prefix = none) %}
{{ return(adapter.dispatch('get_yauaa_context_fields', 'snowplow_web')(table_prefix)) }}
{%- endmacro -%}


Depends On

Referenced By

Iab Fieldsโ€‹

macros/bigquery/page_view_contexts.sql

Description

This macro is used to return the appropriate field and type mapping for use in snowplow_utils.get_optional_fields.

Returns

The specific fields and their type for the context (see macro code for values).

Details

Code
Source
{% macro iab_fields() %}

{% set iab_fields = [
{'field':'category', 'dtype':'string'},
{'field':'primary_impact', 'dtype':'string'},
{'field':'reason', 'dtype':'string'},
{'field':'spider_or_robot', 'dtype':'boolean'}
] %}

{{ return(iab_fields) }}

{% endmacro %}

Referenced By

Stitch User Identifiersโ€‹

macros/stitch_user_identifiers.sql

Description

This macro is used as a post-hook on the sessions table to stitch user identities using the user_mapping table provided.

Arguments

  • enabled (boolean): If the user stitching should be done or not
  • relation (string): (Optional) The model to update the stitched_user_id column in. Default this
  • user_mapping_relation (string): (Optional) The model to use the user_id column from. Default snowplow_web_user_mapping

Returns

The update/merge statement to update the stitched_user_id column, if enabled.

Details

Code
Source
{% macro stitch_user_identifiers(enabled, relation=this, user_mapping_relation='snowplow_web_user_mapping') %}
{{ return(adapter.dispatch('stitch_user_identifiers', 'snowplow_web')(enabled, relation, user_mapping_relation)) }}
{%- endmacro -%}


Referenced By

Ua Fieldsโ€‹

macros/bigquery/page_view_contexts.sql

Description

This macro is used to return the appropriate field and type mapping for use in snowplow_utils.get_optional_fields.

Returns

The specific fields and their type for the context (see macro code for values).

Details

Code
Source
{% macro ua_fields() %}

{% set ua_fields = [
{'field': 'useragent_family', 'dtype': 'string'},
{'field': 'useragent_major', 'dtype': 'string'},
{'field': 'useragent_minor', 'dtype': 'string'},
{'field': 'useragent_patch', 'dtype': 'string'},
{'field': 'useragent_version', 'dtype': 'string'},
{'field': 'os_family', 'dtype': 'string'},
{'field': 'os_major', 'dtype': 'string'},
{'field': 'os_minor', 'dtype': 'string'},
{'field': 'os_patch', 'dtype': 'string'},
{'field': 'os_patch_minor', 'dtype': 'string'},
{'field': 'os_version', 'dtype': 'string'},
{'field': 'device_family', 'dtype': 'string'}
] %}

{{ return(ua_fields) }}

{% endmacro %}

Referenced By

macros/cluster_by_fields.sql

Description

This macro is used to return the appropriate cluster_by fields for the table, depending on the warehouse target.

Returns

The specific fields for each warehouse (see macro code for values).

Details

Code
Source
{% macro web_cluster_by_fields_consent() %}

{{ return(adapter.dispatch('web_cluster_by_fields_consent', 'snowplow_web')()) }}

{% endmacro %}

Depends On

Referenced By

Web Cluster By Fields Cwvโ€‹

macros/cluster_by_fields.sql

Description

This macro does not currently have a description.

Details

Code
Source
{% macro web_cluster_by_fields_cwv() %}

{{ return(adapter.dispatch('web_cluster_by_fields_cwv', 'snowplow_web')()) }}

{% endmacro %}

Depends On

Referenced By

Web Cluster By Fields Page Viewsโ€‹

macros/cluster_by_fields.sql

Description

This macro is used to return the appropriate cluster_by fields for the table, depending on the warehouse target.

Returns

The specific fields for each warehouse (see macro code for values).

Details

Code
Source
{% macro web_cluster_by_fields_page_views() %}

{{ return(adapter.dispatch('web_cluster_by_fields_page_views', 'snowplow_web')()) }}

{% endmacro %}

Depends On

Referenced By

Web Cluster By Fields Sessionsโ€‹

macros/cluster_by_fields.sql

Description

This macro is used to return the appropriate cluster_by fields for the table, depending on the warehouse target.

Returns

The specific fields for each warehouse (see macro code for values).

Details

Code
Source
{% macro web_cluster_by_fields_sessions() %}

{{ return(adapter.dispatch('web_cluster_by_fields_sessions', 'snowplow_web')()) }}

{% endmacro %}

Depends On

Referenced By

Web Cluster By Fields Sessions Lifecycleโ€‹

macros/cluster_by_fields.sql

Description

This macro is used to return the appropriate cluster_by fields for the table, depending on the warehouse target.

Returns

The specific fields for each warehouse (see macro code for values).

Details

Code
Source
{% macro web_cluster_by_fields_sessions_lifecycle() %}

{{ return(adapter.dispatch('web_cluster_by_fields_sessions_lifecycle', 'snowplow_web')()) }}

{% endmacro %}

Depends On

Referenced By

Web Cluster By Fields Usersโ€‹

macros/cluster_by_fields.sql

Description

This macro is used to return the appropriate cluster_by fields for the table, depending on the warehouse target.

Returns

The specific fields for each warehouse (see macro code for values).

Details

Code
Source
{% macro web_cluster_by_fields_users() %}

{{ return(adapter.dispatch('web_cluster_by_fields_users', 'snowplow_web')()) }}

{% endmacro %}

Depends On

Referenced By

Yauaa Fieldsโ€‹

macros/bigquery/page_view_contexts.sql

Description

This macro is used to return the appropriate field and type mapping for use in snowplow_utils.get_optional_fields.

Returns

The specific fields and their type for the context (see macro code for values).

Details

Code
Source
{% macro yauaa_fields() %}

{% set yauaa_fields = [
{'field': 'device_class', 'dtype': 'string'},
{'field': 'agent_class', 'dtype': 'string'},
{'field': 'agent_name', 'dtype': 'string'},
{'field': 'agent_name_version', 'dtype': 'string'},
{'field': 'agent_name_version_major', 'dtype': 'string'},
{'field': 'agent_version', 'dtype': 'string'},
{'field': 'agent_version_major', 'dtype': 'string'},
{'field': 'device_brand', 'dtype': 'string'},
{'field': 'device_name', 'dtype': 'string'},
{'field': 'device_version', 'dtype': 'string'},
{'field': 'layout_engine_class', 'dtype': 'string'},
{'field': 'layout_engine_name', 'dtype': 'string'},
{'field': 'layout_engine_name_version', 'dtype': 'string'},
{'field': 'layout_engine_name_version_major', 'dtype': 'string'},
{'field': 'layout_engine_version', 'dtype': 'string'},
{'field': 'layout_engine_version_major', 'dtype': 'string'},
{'field': 'operating_system_class', 'dtype': 'string'},
{'field': 'operating_system_name', 'dtype': 'string'},
{'field': 'operating_system_name_version', 'dtype': 'string'},
{'field': 'operating_system_version', 'dtype': 'string'}
] %}

{{ return(yauaa_fields) }}

{% endmacro %}

Referenced By

Was this page helpful?