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

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

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 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

  • macro.dbt.type_string

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

  • macro.dbt.type_string

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

  • macro.dbt.type_string

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 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?