{"id":10866,"date":"2025-08-07T07:16:19","date_gmt":"2025-08-07T07:16:19","guid":{"rendered":"https:\/\/www.hopmann.com\/blog\/daten-dbt-test-und-freshness-funktionen\/"},"modified":"2025-10-10T13:22:24","modified_gmt":"2025-10-10T13:22:24","slug":"dbt-jinja-business-logik-wiederverwenden","status":"publish","type":"blog","link":"https:\/\/www.hopmann.com\/en\/blog\/apply-business-logic-reusably-with-dbt-and-jinja-templates\/","title":{"rendered":"Apply Business Logic Reusably with dbt and Jinja Templates"},"content":{"rendered":"<hr>\n<ul>\n<li><a href=\"#\">social<\/a>\n<\/li>\n<\/ul>\n<hr>\n<div>\n<p><strong>dbt und Jinja ist Teil 3 unserer Blogreihe zur Verwendung von <a href=\"https:\/\/www.hopmann.com\/en\/technologien\/dbt\/\">dbt<\/a> modernen <a href=\"https:\/\/www.hopmann.com\/en\/marketing-analytics\/marketing-data-stack\/\">Marketing Data Stack<\/a>, die sich insbesondere an BI Manager, Data Analysts, Analytics Engineers &amp; Co. richtet.<\/strong><\/p>\n<p>Im ersten Artikel unserer <a href=\"https:\/\/www.hopmann.com\/en\/blog\/wie-dbt-ihren-marketing-data-stack-revolutioniert-teil-1\/\" title=\"dbt-Blogpost-Serie\">dbt-Blogpost-Serie<\/a> sind wir darauf eingegangen, wie dbt komplexe SQL-Workflows vereinfacht und die Verwaltung von Marketing-Daten-Pipelines erleichtert. Im <a href=\"https:\/\/www.hopmann.com\/en\/blog\/daten-dbt-test-und-freshness-funktionen\/\">zweiten Teil<\/a> haben wir gezeigt, wie dbt Teams bei der Sicherstellung ihrer Datenqualit\u00e4t unterst\u00fctzt: mit automatisierten Tests auf Schema-Ebene (unique, not_null, accepted_values oder relationships) und Freshness-Tests, um veraltete Daten fr\u00fchzeitig zu erkennen, bevor sie <a href=\"https:\/\/www.hopmann.com\/en\/marketing-analytics\/marketing-dashboards-reports\/\">Dashboards oder Reports<\/a> beeinflussen.<\/p>\n<\/div>\n<h2>Herausforderung im Marketing: Wiederkehrende Logik, viele Datenquellen<\/h2>\n<div>\n<p>In dynamischen Marketing-Umfeldern muss dieselbe Business-Logik oft auf unterschiedliche Datenquellen angewendet werden. Typische Beispiele sind das Extrahieren von UTM-Parametern aus URLs, die Standardisierung von Kampagnennamen oder die Normalisierung von Plattformbezeichnungen (z. B. Instagram, Facebook, TikTok).<\/p>\n<p>In klassischen SQL-Workflows, etwa direkt in <a href=\"https:\/\/www.hopmann.com\/en\/technologien\/snowflake\/\">Snowflake<\/a>, wird diese Logik oft per Copy-Paste \u00fcber verschiedene Modelle verteilt. Das f\u00fchrt zu doppeltem Code, inkonsistenten Ergebnissen und schwer wartbarem SQL.<\/p>\n<\/div>\n<h2>L\u00f6sung: Wiederverwendbare Logik mit dbt und Jinja<\/h2>\n<div>\n<p>dbt l\u00f6st dieses Problem mit Hilfe von Jinja Templates. Jinja ist eine schlanke Template-Sprache, mit der sich Steuerlogik wie Schleifen oder Bedingungen (loops, if\/else conditions) direkt in SQL-Modelle integrieren l\u00e4sst, \u00fcber sogenannte Macros, die wiederverwendbar sind.<\/p>\n<\/div>\n<h3>Die wichtigsten Vorteile von Jinja Templates in dbt<\/h3>\n<div>\n<ul>\n<li><strong>Wiederverwendbare Logik:<\/strong> Einmal definiert, in beliebig vielen Modellen nutzbar<\/li>\n<li><strong>\u00dcbersichtliche Modelle:<\/strong> Gesch\u00e4ftslogik bleibt im Fokus, wiederkehrender Code wird ausgelagert<\/li>\n<li><strong>Konsistenz \u00fcber Teams und Datenquellen hinweg:<\/strong> Gemeinsame Macros sorgen f\u00fcr einheitliche Berechnungen<\/li>\n<li><strong>Einfache Wartung:<\/strong> Eine \u00c4nderung im Macro aktualisiert alle Abh\u00e4ngigkeiten automatisch<\/li>\n<\/ul>\n<\/div>\n<h3>Ein Beispiel aus der Praxis: UTM-Parameter vereinheitlichen<\/h3>\n<div>\n<p>Stellen wir uns vor, ein Unternehmen sammelt Kampagnendaten aus Facebook, Google Ads, LinkedIn und TikTok. Jede Quelle liefert Click-URLs in einem anderen Format. Das Ziel ist es jeodch, einheitliche UTM-Parameter wie utm_campaign oder utm_source daraus zu extrahieren.<\/p>\n<p>Mit dbt lassen sich daf\u00fcr wiederverwendbare Macros erstellen, die einmal definiert und \u00fcberall angewendet werden k\u00f6nnen, z. B. um URLs zu bereinigen oder UTM-Parameter herauszufiltern.<\/p>\n<\/div>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/Hopmann_dbt_Blogpost_Jinja-1.png\" alt=\"Hopmann_dbt_Blogpost_Jinja-1\"><\/p>\n<pre><code>-- macros\/clean_url.sql\r\n{% macro clean_url(column_name) %}\r\n    LOWER(\r\n        REPLACE(\r\n            REPLACE(\r\n                REPLACE(\r\n                    REPLACE(\r\n                        REPLACE(\r\n                            REPLACE(\r\n                                REPLACE(\r\n                                    DECODE_URL(\r\n                                        SPLIT_PART(SPLIT_PART({{ column_name }}, '?', 1), '#', 1)\r\n                                    ),\r\n                                    'https:\/\/', ''\r\n                                ),\r\n                                'http:\/\/', ''\r\n                            ),\r\n                            '\u00f6', 'oe'\r\n                        ),\r\n                        '\u00fc', 'ue'\r\n                    ),\r\n                    '\u00e4', 'ae'\r\n                ),\r\n                '\u00df', 'ss'\r\n            )\r\n        )\r\n    )\r\n{% endmacro %}<\/code><\/pre>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/Hopmann_dbt_Blogpost_Jinja-2.png\" alt=\"Hopmann_dbt_Blogpost_Jinja-2\"><\/p>\n<pre><code>-- macros\/extract_utm_params.sql\r\n{% macro extract_utm_params(url_col) %}\r\n  regexp_extract({{ url_col }}, '(?:[?&amp;])utm_source=([^&amp;]+)', 1) as utm_source,\r\n  regexp_extract({{ url_col }}, '(?:[?&amp;])utm_medium=([^&amp;]+)', 1) as utm_medium,\r\n  regexp_extract({{ url_col }}, '(?:[?&amp;])utm_campaign=([^&amp;]+)', 1) as utm_campaign,\r\n  regexp_extract({{ url_col }}, '(?:[?&amp;])utm_content=([^&amp;]+)', 1) as utm_content,\r\n  regexp_extract({{ url_col }}, '(?:[?&amp;])utm_term=([^&amp;]+)', 1) as utm_term\r\n{% endmacro %}<\/code><\/pre>\n<div>\n<p>Verwendung desselben Codes in verschiedenen Dateien und Modellen:<\/p>\n<\/div>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/Hopmann_dbt_Blogpost_Jinja-3.png\" alt=\"Hopmann_dbt_Blogpost_Jinja-3\"><\/p>\n<pre><code>-- models\/intermediate\/facebook_campaigns.sql\r\nSELECT\r\n  account_id,\r\n\t....\r\n  {{ clean_url(url') }} AS cleaned_click_url,\r\n  {{ extract_utm_params('cleaned_click_url') }}\r\n\t....\r\nFROM {{ source('facebook_ads', 'campaigns') }}\r\n\r\n-- models\/intermediate\/linkedin_campaigns.sql\r\nSELECT\r\n  account_id,\r\n\t....\r\n  {{ clean_url(url') }} AS cleaned_click_url,\r\n  {{ extract_utm_params('cleaned_click_url') }}\r\n\t....\r\nFROM {{ source('linkedin_ads', 'campaigns') }}\r\n\r\n-- models\/intermediate\/outbrain_campaigns.sql\r\nSELECT\r\n  account_id,\r\n\t....\r\n  {{ clean_url(url') }} AS cleaned_click_url,\r\n  {{ extract_utm_params('cleaned_click_url') }}\r\n\t....\r\nFROM {{ source('outbrain_ads', 'campaigns') }}<\/code><\/pre>\n<h2>Fazit: Warum dbt eine wichtige Rolle in Marketing Analytics spielt<\/h2>\n<div>\n<p>Der moderne Marketing Data Stack erfordert Flexibilit\u00e4t, Geschwindigkeit und Vertrauen in gro\u00dfem Ma\u00dfstab. In Kombination mit einem leistungsstarken Data Warehouse wie <a href=\"https:\/\/www.hopmann.com\/en\/technologien\/snowflake\/\">Snowflake<\/a> bringt <a href=\"https:\/\/www.hopmann.com\/de\/technologien\/dbt\/\">dbt<\/a> eine Ebene der strategischen Transformation in den Stack: Prozesse werden vereinfacht, Datenqualit\u00e4t wird sichergestellt und Wiederverwendbarkeit gef\u00f6rdert.<\/p>\n<p>Lassen Sie uns die zentralen Vorteile von dbt f\u00fcr Marketing-Teams zusammenfassen:<\/p>\n<ul>\n<li><strong>Vereinfachte Transformationen:<\/strong> Deklarative SQL-Modelle ersetzen komplexe, prozedurale Logik und machen Datenpipelines leichter lesbar und wartbar<\/li>\n<li><strong>Integrierte Tests und Monitoring:<\/strong> Stellen sicher, dass KPIs verl\u00e4sslich bleiben und Dashboards auch bei mehreren Plattformen stabil funktionieren<\/li>\n<li><strong>Wiederverwendbare, skalierbare Gesch\u00e4ftslogik:<\/strong> Jinja Templates sorgen f\u00fcr Konsistenz und reduzieren redundanten Code \u00fcber Plattformen wie Facebook, LinkedIn oder TikTok hinweg<\/li>\n<\/ul>\n<p>Kurz gesagt: Mit dbt verbringt Ihr Team weniger Zeit mit Debugging und mehr Zeit mit Erkenntnissen. Wer einen modernen, verl\u00e4sslichen Marketing Analytics Stack aufbauen will, sollte dbt als eine Option f\u00fcr eine zentrale Komponente in Betracht ziehen.<\/p>\n<p><a href=\"https:\/\/www.hopmann.com\/en\/kontakt\/\">Wir unterst\u00fctzen Sie gerne<\/a>: sei es beim Einstieg mit <a href=\"https:\/\/www.hopmann.com\/de\/academy\/dbt-datenmodellierung\/\">dbt<\/a>, bei der Auswahl der richtigen Struktur oder wenn Sie in einem laufenden Projekt nicht weiterkommen.<\/p>\n<\/div>\n<p><p>\n        <a href=\"https:\/\/www.hopmann.com\/de\/academy\/dbt-datenmodellierung\/\">dbt Training<\/a>\n    <\/p>\n<\/p>\n<p><p>\n        <a href=\"https:\/\/www.hopmann.com\/de\/technologien\/dbt\/\">dbt Beratung<\/a>\n    <\/p>\n<\/p>\n<hr>\n<p><p>\n        Vorheriger Artikel    <\/p>\n<\/p>\n<p><p>\n        N\u00e4chster Artikel    <\/p>\n<\/p>\n<hr>\n<div>Neueste Artikel<\/div>\n<div>\n<\/div>\n<div>Kategorien<\/div>\n<div>\n<\/div>\n<p><!--more--><br \/>\n<!-- {\"type\":\"layout\",\"children\":[{\"type\":\"section\",\"props\":{\"animation\":\"slide-bottom-medium\",\"animation_delay\":\"50\",\"height\":\"page\",\"image_position\":\"center-center\",\"padding\":\"large\",\"padding_remove_top\":true,\"style\":\"default\",\"title_breakpoint\":\"xl\",\"title_position\":\"top-left\",\"title_rotation\":\"left\",\"vertical_align\":\"\",\"width\":\"large\"},\"children\":[{\"type\":\"row\",\"props\":{\"column_gap\":\"large\",\"layout\":\"2-3,1-3\",\"padding_remove_horizontal\":false,\"row_gap\":\"large\"},\"children\":[{\"type\":\"column\",\"props\":{\"image_position\":\"center-center\",\"position_sticky_breakpoint\":\"m\",\"width_large\":\"2-3\"},\"children\":[{\"type\":\"headline\",\"props\":{\"margin_remove_bottom\":true,\"title_element\":\"div\",\"title_style\":\"text-meta\"},\"source_extended\":{\"props\":{\"content\":{\"composed\":{\"value\":\"{{ sources.6b78 }}: {{ sources.46d0 }}\",\"sources\":{\"6b78\":{\"name\":\"field.datum\",\"query\":{\"name\":\"#parent\"},\"filters\":{\"search\":\"\",\"date\":\"d.m.Y\"}},\"46d0\":{\"name\":\"field.subline\",\"query\":{\"name\":\"#parent\"}},\"6ef0\":{\"name\":\"field.datum\",\"query\":{\"name\":\"#parent\"},\"filters\":{\"search\":\"\",\"date\":\"d.m.Y\"}}},\"conditions\":[]}}}}},{\"type\":\"headline\",\"props\":{\"margin\":\"small\",\"margin_remove_top\":false,\"title_element\":\"h1\",\"title_style\":\"h1\"},\"source_extended\":{\"props\":{\"content\":{\"name\":\"title\",\"query\":{\"name\":\"#parent\"}}}}},{\"type\":\"divider\",\"props\":{\"divider_element\":\"hr\",\"margin\":\"medium\",\"margin_remove_bottom\":true}},{\"type\":\"fragment\",\"props\":{\"margin\":\"remove-vertical\"},\"children\":[{\"type\":\"row\",\"props\":{\"css\":\".el-row {\\n\\tmargin-top: 8px;\\n    margin-bottom: 8px;\\n}\",\"layout\":\"1-2,1-2\",\"margin\":\"large\",\"yooessentials_access_conditions\":[],\"yooessentials_access_mode\":\"AND\"},\"children\":[{\"type\":\"column\",\"props\":{\"image_position\":\"center-center\",\"position_sticky_breakpoint\":\"m\",\"vertical_align\":\"middle\",\"width_default\":\"1-2\"},\"children\":[{\"type\":\"panel\",\"props\":{\"content_column_breakpoint\":\"m\",\"icon_width\":80,\"image_align\":\"left\",\"image_border\":\"circle\",\"image_grid_breakpoint\":\"\",\"image_grid_column_gap\":\"small\",\"image_grid_row_gap\":\"medium\",\"image_grid_width\":\"auto\",\"image_height\":40,\"image_svg_color\":\"emphasis\",\"image_vertical_align\":true,\"image_width\":40,\"link_style\":\"default\",\"link_text\":\"Read more\",\"margin\":\"\",\"meta_align\":\"below-title\",\"meta_element\":\"div\",\"meta_style\":\"text-meta\",\"title_align\":\"top\",\"title_element\":\"h3\",\"title_font_family\":\"tertiary\",\"title_grid_breakpoint\":\"m\",\"title_grid_width\":\"1-2\",\"title_hover_style\":\"reset\",\"title_style\":\"text-small\"},\"source_extended\":{\"props\":{\"image\":{\"name\":\"field.foto.url\",\"query\":{\"name\":\"#parent\"}},\"title\":{\"composed\":{\"value\":\"\",\"sources\":[],\"conditions\":[]}},\"content\":{\"composed\":{\"value\":\"{{ sources.5d02 }}, {{ sources.67e8 }}\",\"sources\":{\"5d02\":{\"name\":\"field.autor\",\"query\":{\"name\":\"#parent\"},\"filters\":{\"search\":\"\"}},\"67e8\":{\"name\":\"field.datum\",\"query\":{\"name\":\"#parent\"},\"filters\":{\"search\":\"\",\"date\":\"d.m.Y\"}}},\"conditions\":[]}},\"content_en_us\":{\"composed\":{\"value\":\"{{ sources.cce3 }} on {{ sources.4656 }}\",\"sources\":{\"4656\":{\"name\":\"date\",\"query\":{\"name\":\"blogs.singleBlog\"},\"filters\":{\"date\":\"\"}},\"cce3\":{\"filters\":{\"search\":\"\"},\"name\":\"field.autor\",\"query\":{\"name\":\"blogs.singleBlog\"}}},\"conditions\":[]}}}},\"name\":\"Verfasser\"}]},{\"type\":\"column\",\"props\":{\"image_position\":\"center-center\",\"position_sticky_breakpoint\":\"m\",\"vertical_align\":\"middle\",\"width_default\":\"1-2\"},\"children\":[{\"type\":\"yooessentials_social_sharing\",\"props\":{\"class\":\"social-sharing-blog\",\"grid\":\"horizontal\",\"grid_column_gap\":\"small\",\"grid_row_gap\":\"small\",\"image_svg_inline\":true,\"link_style\":\"link\",\"margin\":\"default\",\"text_align\":\"right\"},\"children\":[{\"type\":\"yooessentials_social_sharing_item\",\"props\":{\"link_target\":\"_blank\",\"link_target_height\":\"\",\"link_target_width\":\"\",\"network\":\"linkedin\"}}],\"name\":\"Teilen\"}]}]}]},{\"type\":\"divider\",\"props\":{\"divider_element\":\"hr\",\"margin\":\"medium\",\"margin_remove_top\":true}},{\"type\":\"html\",\"props\":{\"content\":\"\"},\"name\":\"--- \\\/\\\/ Content Start \\\/\\\/ ---\"},{\"type\":\"text\",\"props\":{\"column_breakpoint\":\"m\",\"content\":\"\n\n<p><strong>dbt und Jinja ist Teil 3 unserer Blogreihe zur Verwendung von <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/technologien\\\/dbt\\\/\\\">dbt<\\\/a> modernen <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/marketing-analytics\\\/marketing-data-stack\\\/\\\">Marketing Data Stack<\\\/a>, die sich insbesondere an BI Manager, Data Analysts, Analytics Engineers &amp; Co. richtet.<\\\/strong><\\\/p>\\n\n\n<p>Im ersten Artikel unserer <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/blog\\\/wie-dbt-ihren-marketing-data-stack-revolutioniert-teil-1\\\/\\\" title=\\\"dbt-Blogpost-Serie\\\">dbt-Blogpost-Serie<\\\/a> sind wir darauf eingegangen, wie dbt komplexe SQL-Workflows vereinfacht und die Verwaltung von Marketing-Daten-Pipelines erleichtert. Im <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/blog\\\/daten-dbt-test-und-freshness-funktionen\\\/\\\">zweiten Teil<\\\/a> haben wir gezeigt, wie dbt Teams bei der Sicherstellung ihrer Datenqualit\\u00e4t unterst\\u00fctzt: mit automatisierten Tests auf Schema-Ebene (unique, not_null, accepted_values oder relationships) und Freshness-Tests, um veraltete Daten fr\\u00fchzeitig zu erkennen, bevor sie <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/marketing-analytics\\\/marketing-dashboards-reports\\\/\\\">Dashboards oder Reports<\\\/a> beeinflussen.<\\\/p>\",\"content_en_us\":\"\n\n<p><strong>This is part 3 of our blog series on using <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/technologies\\\/dbt\\\/\\\">dbt<\\\/a> in the modern <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/marketing-analytics\\\/marketing-data-stack\\\/\\\">marketing data stack<\\\/a>, aimed especially at BI managers, data analysts, analytics engineers, and similar roles.<\\\/strong><\\\/p>\\n\n\n<p>In the <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/blog\\\/how-dbt-can-revolutionize-your-marketing-data-stack-part-1\\\/\\\">first article of our dbt blog series<\\\/a>, we explained how dbt simplifies complex SQL workflows and makes it easier to manage marketing data pipelines. In the <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/blog\\\/data-quality-dbt-test-and-freshness-functions\\\/\\\">second blogpost<\\\/a>, we explored how dbt empowers teams to enforce data quality using automated testing, including schema-level checks (like unique, not_null, accepted_values, and relationships) and source freshness tests to detect stale data before it affects <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/marketing-analytics\\\/marketing-dashboards-reports\\\/\\\">dashboards and reporting<\\\/a>.<\\\/p>\",\"margin\":\"medium\",\"margin_remove_top\":true,\"text_style\":\"large\"},\"name\":\"Lead-Text\"},{\"type\":\"headline\",\"props\":{\"content\":\"Herausforderung im Marketing: Wiederkehrende Logik, viele Datenquellen\",\"content_en_us\":\"The Challenge: Repeating Logic Across Many Marketing Sources\",\"margin\":\"default\",\"margin_remove_bottom\":false,\"title_element\":\"h2\",\"title_style\":\"h2\"}},{\"type\":\"text\",\"props\":{\"column_breakpoint\":\"m\",\"content\":\"\n\n<p>In dynamischen Marketing-Umfeldern muss dieselbe Business-Logik oft auf unterschiedliche Datenquellen angewendet werden. Typische Beispiele sind das Extrahieren von UTM-Parametern aus URLs, die Standardisierung von Kampagnennamen oder die Normalisierung von Plattformbezeichnungen (z. B. Instagram, Facebook, TikTok).<\\\/p>\\n\n\n<p>In klassischen SQL-Workflows, etwa direkt in <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/technologien\\\/snowflake\\\/\\\">Snowflake<\\\/a>, wird diese Logik oft per Copy-Paste \\u00fcber verschiedene Modelle verteilt. Das f\\u00fchrt zu doppeltem Code, inkonsistenten Ergebnissen und schwer wartbarem SQL.<\\\/p>\",\"content_en_us\":\"\n\n<p>In fast-moving marketing environments, the same business logic often needs to be applied across multiple data sources like extracting UTM parameters from URLs, standardizing campaign names, or normalizing platforms (e.g. Instagram, Facebook, TikTok).<\\\/p>\\n\n\n<p>In traditional SQL workflows (e.g. within <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/technologies\\\/snowflake\\\/\\\">Snowflake<\\\/a>), this means copying and pasting logic across models. This leads to duplication, inconsistent results, and hard-to-maintain code.<\\\/p>\",\"margin\":\"medium\",\"margin_remove_top\":true,\"text_style\":\"large\"}},{\"type\":\"headline\",\"props\":{\"content\":\"L\\u00f6sung: Wiederverwendbare Logik mit dbt und Jinja\",\"content_en_us\":\"The Solution: Reusable Logic with dbt and Jinja\",\"margin\":\"default\",\"margin_remove_bottom\":false,\"title_element\":\"h2\",\"title_style\":\"h2\"}},{\"type\":\"text\",\"props\":{\"column_breakpoint\":\"m\",\"content\":\"\n\n<p>dbt l\\u00f6st dieses Problem mit Hilfe von Jinja Templates. Jinja ist eine schlanke Template-Sprache, mit der sich Steuerlogik wie Schleifen oder Bedingungen (loops, if\\\/else conditions) direkt in SQL-Modelle integrieren l\\u00e4sst, \\u00fcber sogenannte Macros, die wiederverwendbar sind.<\\\/p>\",\"content_en_us\":\"\n\n<p>dbt solves this with Jinja templating. Jinja is a lightweight templating language that lets you embed control logic (like loops and if\\\/else conditions) directly into your SQL models via reusable macros.<\\\/p>\",\"margin\":\"medium\",\"margin_remove_top\":true,\"text_style\":\"large\"}},{\"type\":\"headline\",\"props\":{\"content\":\"Die wichtigsten Vorteile von Jinja Templates in dbt\",\"content_en_us\":\"Key Benefits of Using Jinja Templates in dbt\",\"title_element\":\"h3\",\"title_style\":\"h3\"}},{\"type\":\"text\",\"props\":{\"column_breakpoint\":\"m\",\"content\":\"\n\n<ul>\\n\n\n<li><strong>Wiederverwendbare Logik:<\\\/strong> Einmal definiert, in beliebig vielen Modellen nutzbar<\\\/li>\\n\n\n<li><strong>\\u00dcbersichtliche Modelle:<\\\/strong> Gesch\\u00e4ftslogik bleibt im Fokus, wiederkehrender Code wird ausgelagert<\\\/li>\\n\n\n<li><strong>Konsistenz \\u00fcber Teams und Datenquellen hinweg:<\\\/strong> Gemeinsame Macros sorgen f\\u00fcr einheitliche Berechnungen<\\\/li>\\n\n\n<li><strong>Einfache Wartung:<\\\/strong> Eine \\u00c4nderung im Macro aktualisiert alle Abh\\u00e4ngigkeiten automatisch<\\\/li>\\n<\\\/ul>\",\"content_en_us\":\"\n\n<ul>\\n\n\n<li><strong>Reusable logic:<\\\/strong> Define once, use everywhere. Macros let you encapsulate complex SQL logic and call it across models.<\\\/li>\\n\n\n<li><strong>Clean, focused models:<\\\/strong> Business logic stays front and center, while repetitive code is abstracted away.<\\\/li>\\n\n\n<li><strong>Consistent output:<\\\/strong> Shared macros prevent mismatches in calculations across teams or data sources.<\\\/li>\\n\n\n<li><strong>Easy maintenance:<\\\/strong> Update a macro in one place and instantly propagate changes project-wide.<\\\/li>\\n<\\\/ul>\",\"margin\":\"medium\",\"margin_remove_top\":true,\"text_style\":\"large\"}},{\"type\":\"headline\",\"props\":{\"content\":\"Ein Beispiel aus der Praxis: UTM-Parameter vereinheitlichen\",\"content_en_us\":\"Practical example: Standardizing UTM Parameter Extraction\",\"title_element\":\"h3\",\"title_style\":\"h3\"}},{\"type\":\"text\",\"props\":{\"column_breakpoint\":\"m\",\"content\":\"\n\n<p>Stellen wir uns vor, ein Unternehmen sammelt Kampagnendaten aus Facebook, Google Ads, LinkedIn und TikTok. Jede Quelle liefert Click-URLs in einem anderen Format. Das Ziel ist es jeodch, einheitliche UTM-Parameter wie utm_campaign oder utm_source daraus zu extrahieren.<\\\/p>\\n\n\n<p>Mit dbt lassen sich daf\\u00fcr wiederverwendbare Macros erstellen, die einmal definiert und \\u00fcberall angewendet werden k\\u00f6nnen, z. B. um URLs zu bereinigen oder UTM-Parameter herauszufiltern.<\\\/p>\",\"content_en_us\":\"\n\n<p>Imagine you're collecting campaign data from Facebook, Google Ads, LinkedIn, and TikTok. Each source logs click URLs differently, but you want to extract consistent UTM parameters (utm_campaign, utm_source, etc.) from those URLs.<\\\/p>\\n\n\n<p>With dbt, you can build reusable macros to handle this once and apply it everywhere.<\\\/p>\",\"margin\":\"medium\",\"margin_remove_top\":true,\"text_style\":\"large\"}},{\"type\":\"image\",\"props\":{\"image\":\"wp-content\\\/uploads\\\/Hopmann_dbt_Blogpost_Jinja-1.png\",\"image_alt\":\"Hopmann_dbt_Blogpost_Jinja-1\",\"image_svg_color\":\"emphasis\",\"image_width\":900,\"margin\":\"small\",\"margin_remove_bottom\":false,\"margin_remove_top\":false}},{\"type\":\"code\",\"props\":{\"content\":\"-- macros\\\/clean_url.sql\\n{% macro clean_url(column_name) %}\\n    LOWER(\\n        REPLACE(\\n            REPLACE(\\n                REPLACE(\\n                    REPLACE(\\n                        REPLACE(\\n                            REPLACE(\\n                                REPLACE(\\n                                    DECODE_URL(\\n                                        SPLIT_PART(SPLIT_PART({{ column_name }}, '?', 1), '#', 1)\\n                                    ),\\n                                    'https:\\\/\\\/', ''\\n                                ),\\n                                'http:\\\/\\\/', ''\\n                            ),\\n                            '\\u00f6', 'oe'\\n                        ),\\n                        '\\u00fc', 'ue'\\n                    ),\\n                    '\\u00e4', 'ae'\\n                ),\\n                '\\u00df', 'ss'\\n            )\\n        )\\n    )\\n{% endmacro %}\"}},{\"type\":\"image\",\"props\":{\"image\":\"wp-content\\\/uploads\\\/Hopmann_dbt_Blogpost_Jinja-2.png\",\"image_alt\":\"Hopmann_dbt_Blogpost_Jinja-2\",\"image_svg_color\":\"emphasis\",\"image_width\":900,\"margin\":\"small\",\"margin_remove_bottom\":false,\"margin_remove_top\":false}},{\"type\":\"code\",\"props\":{\"content\":\"-- macros\\\/extract_utm_params.sql\\n{% macro extract_utm_params(url_col) %}\\n  regexp_extract({{ url_col }}, '(?:[?&])utm_source=([^&]+)', 1) as utm_source,\\n  regexp_extract({{ url_col }}, '(?:[?&])utm_medium=([^&]+)', 1) as utm_medium,\\n  regexp_extract({{ url_col }}, '(?:[?&])utm_campaign=([^&]+)', 1) as utm_campaign,\\n  regexp_extract({{ url_col }}, '(?:[?&])utm_content=([^&]+)', 1) as utm_content,\\n  regexp_extract({{ url_col }}, '(?:[?&])utm_term=([^&]+)', 1) as utm_term\\n{% endmacro %}\"}},{\"type\":\"text\",\"props\":{\"column_breakpoint\":\"m\",\"content\":\"\n\n<p>Verwendung desselben Codes in verschiedenen Dateien und Modellen:<\\\/p>\",\"content_en_us\":\"\n\n<p>And use the same code across different files and models:<\\\/p>\",\"margin\":\"medium\",\"margin_remove_top\":true,\"text_style\":\"large\"}},{\"type\":\"image\",\"props\":{\"image\":\"wp-content\\\/uploads\\\/Hopmann_dbt_Blogpost_Jinja-3.png\",\"image_alt\":\"Hopmann_dbt_Blogpost_Jinja-3\",\"image_svg_color\":\"emphasis\",\"image_width\":900,\"margin\":\"small\",\"margin_remove_bottom\":false,\"margin_remove_top\":false}},{\"type\":\"code\",\"props\":{\"content\":\"-- models\\\/intermediate\\\/facebook_campaigns.sql\\nSELECT\\n  account_id,\\n\\t....\\n  {{ clean_url(url') }} AS cleaned_click_url,\\n  {{ extract_utm_params('cleaned_click_url') }}\\n\\t....\\nFROM {{ source('facebook_ads', 'campaigns') }}\\n\\n-- models\\\/intermediate\\\/linkedin_campaigns.sql\\nSELECT\\n  account_id,\\n\\t....\\n  {{ clean_url(url') }} AS cleaned_click_url,\\n  {{ extract_utm_params('cleaned_click_url') }}\\n\\t....\\nFROM {{ source('linkedin_ads', 'campaigns') }}\\n\\n-- models\\\/intermediate\\\/outbrain_campaigns.sql\\nSELECT\\n  account_id,\\n\\t....\\n  {{ clean_url(url') }} AS cleaned_click_url,\\n  {{ extract_utm_params('cleaned_click_url') }}\\n\\t....\\nFROM {{ source('outbrain_ads', 'campaigns') }}\"}},{\"type\":\"headline\",\"props\":{\"content\":\"Fazit: Warum dbt eine wichtige Rolle in Marketing Analytics spielt\",\"content_en_us\":\"Conclusion: Why dbt Matters in Marketing Analytics\",\"margin\":\"default\",\"margin_remove_bottom\":false,\"title_element\":\"h2\",\"title_style\":\"h2\"}},{\"type\":\"text\",\"props\":{\"column_breakpoint\":\"m\",\"content\":\"\n\n<p>Der moderne Marketing Data Stack erfordert Flexibilit\\u00e4t, Geschwindigkeit und Vertrauen in gro\\u00dfem Ma\\u00dfstab. In Kombination mit einem leistungsstarken Data Warehouse wie <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/technologien\\\/snowflake\\\/\\\">Snowflake<\\\/a> bringt <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/de\\\/technologien\\\/dbt\\\/\\\">dbt<\\\/a> eine Ebene der strategischen Transformation in den Stack: Prozesse werden vereinfacht, Datenqualit\\u00e4t wird sichergestellt und Wiederverwendbarkeit gef\\u00f6rdert.<\\\/p>\\n\n\n<p>Lassen Sie uns die zentralen Vorteile von dbt f\\u00fcr Marketing-Teams zusammenfassen:<\\\/p>\\n\n\n<ul>\\n\n\n<li><strong>Vereinfachte Transformationen:<\\\/strong> Deklarative SQL-Modelle ersetzen komplexe, prozedurale Logik und machen Datenpipelines leichter lesbar und wartbar<\\\/li>\\n\n\n<li><strong>Integrierte Tests und Monitoring:<\\\/strong> Stellen sicher, dass KPIs verl\\u00e4sslich bleiben und Dashboards auch bei mehreren Plattformen stabil funktionieren<\\\/li>\\n\n\n<li><strong>Wiederverwendbare, skalierbare Gesch\\u00e4ftslogik:<\\\/strong> Jinja Templates sorgen f\\u00fcr Konsistenz und reduzieren redundanten Code \\u00fcber Plattformen wie Facebook, LinkedIn oder TikTok hinweg<\\\/li>\\n<\\\/ul>\\n\n\n<p>Kurz gesagt: Mit dbt verbringt Ihr Team weniger Zeit mit Debugging und mehr Zeit mit Erkenntnissen. Wer einen modernen, verl\\u00e4sslichen Marketing Analytics Stack aufbauen will, sollte dbt als eine Option f\\u00fcr eine zentrale Komponente in Betracht ziehen.<\\\/p>\\n\n\n<p><a href=\\\"https:\\\/\\\/www.hopmann.com\\\/kontakt\\\/\\\">Wir unterst\\u00fctzen Sie gerne<\\\/a>: sei es beim Einstieg mit <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/de\\\/academy\\\/dbt-datenmodellierung\\\/\\\">dbt<\\\/a>, bei der Auswahl der richtigen Struktur oder wenn Sie in einem laufenden Projekt nicht weiterkommen.<\\\/p>\",\"content_en_us\":\"\n\n<p>The modern marketing data stack demands flexibility, speed, and trust at scale. When used alongside a powerful warehouse like <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/technologies\\\/snowflake\\\/\\\">Snowflake<\\\/a>, <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/technologies\\\/dbt\\\/\\\">dbt<\\\/a> brings a strategic layer of transformation that simplifies workflows, enforces data quality, and promotes reusability.<\\\/p>\\n\n\n<p>Let\\u2019s recap the core advantages of dbt for marketing teams:<\\\/p>\\n\n\n<ul>\\n\n\n<li><strong>Simplified transformations:<\\\/strong> Declarative SQL models eliminate complex procedural logic and make pipelines easier to read and maintain<\\\/li>\\n\n\n<li><strong>Embedded testing and monitoring:<\\\/strong> Ensures your KPIs are trustworthy and your dashboards don\\u2019t break, even across multiple platforms<\\\/li>\\n\n\n<li><strong>Reusable, scalable business logic:<\\\/strong> Jinja templates promote consistency and reduce repetitive code across marketing sources like Facebook, LinkedIn, or TikTok<\\\/li>\\n<\\\/ul>\\n\n\n<p>In short, dbt helps your team spend less time debugging pipelines and more time driving insights. If you\\u2019re serious about building a modern, reliable marketing analytics stack, should consider dbt as one option for a central role.<\\\/p>\\n\n\n<p><a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/contact\\\/\\\">We are happy to help<\\\/a> you if you'd like to know more about <a href=\\\"https:\\\/\\\/www.hopmann.com\\\/en\\\/academy\\\/dbt-data-modeling\\\/\\\">dbt<\\\/a>, want to get started or are stuck in a current project.<\\\/p>\",\"margin\":\"medium\",\"margin_remove_top\":true,\"text_style\":\"large\"}},{\"type\":\"button\",\"props\":{\"grid_column_gap\":\"small\",\"grid_row_gap\":\"small\",\"margin\":\"default\"},\"children\":[{\"type\":\"button_item\",\"props\":{\"button_style\":\"default\",\"content\":\"dbt Training\",\"content_en_us\":\"dbt Training\",\"dialog_layout\":\"modal\",\"dialog_offcanvas_flip\":true,\"icon_align\":\"left\",\"link\":\"https:\\\/\\\/www.hopmann.com\\\/de\\\/academy\\\/dbt-datenmodellierung\\\/\",\"link_en_us\":\"https:\\\/\\\/www.hopmann.com\\\/en\\\/academy\\\/dbt-data-modeling\\\/\",\"link_title\":\"dbt Training\",\"link_title_en_us\":\"dbt Training\"}}]},{\"type\":\"button\",\"props\":{\"grid_column_gap\":\"small\",\"grid_row_gap\":\"small\",\"margin\":\"default\"},\"children\":[{\"type\":\"button_item\",\"props\":{\"button_style\":\"default\",\"content\":\"dbt Beratung\",\"content_en_us\":\"dbt Consulting\",\"dialog_layout\":\"modal\",\"dialog_offcanvas_flip\":true,\"icon_align\":\"left\",\"link\":\"https:\\\/\\\/www.hopmann.com\\\/de\\\/technologien\\\/dbt\\\/\",\"link_en_us\":\"https:\\\/\\\/www.hopmann.com\\\/en\\\/technologies\\\/dbt\\\/\",\"link_title\":\"dbt Beratung\",\"link_title_en_us\":\"dbt Consulting\"}}]},{\"type\":\"html\",\"props\":{\"content\":\"\"},\"name\":\"--- \\\/\\\/ Content Ende \\\/\\\/ ---\"},{\"type\":\"fragment\",\"props\":{\"margin\":\"default\"},\"children\":[{\"type\":\"row\",\"props\":{\"css\":\".el-row {\\n\\tmargin-top: 70px;\\n}\",\"margin_remove_bottom\":true},\"children\":[{\"type\":\"column\",\"props\":{\"image_position\":\"center-center\",\"position_sticky_breakpoint\":\"m\"},\"children\":[{\"type\":\"divider\",\"props\":{\"divider_element\":\"hr\"}}]}]},{\"type\":\"row\",\"props\":{\"class\":\"blog-pager\",\"layout\":\"1-2,1-2\",\"margin\":\"small\"},\"children\":[{\"type\":\"column\",\"props\":{\"image_position\":\"center-center\",\"position_sticky_breakpoint\":\"m\",\"width_default\":\"1-2\",\"width_medium\":\"1-2\"},\"children\":[{\"type\":\"button\",\"props\":{\"class\":\"blog-pager\",\"grid_column_gap\":\"small\",\"grid_row_gap\":\"small\",\"margin\":\"remove-vertical\"},\"children\":[{\"type\":\"button_item\",\"props\":{\"button_style\":\"\",\"content\":\"Vorheriger Artikel\",\"content_en_us\":\"Previous article\",\"dialog_layout\":\"modal\",\"dialog_offcanvas_flip\":true,\"icon\":\"chevron-left\",\"icon_align\":\"left\"},\"source\":{\"query\":{\"name\":\"blogs.singlePreviousBlog\"},\"props\":{\"link\":{\"filters\":{\"search\":\"\"},\"name\":\"link\"}}}}]}]},{\"type\":\"column\",\"props\":{\"image_position\":\"center-center\",\"position_sticky_breakpoint\":\"m\",\"width_default\":\"1-2\",\"width_medium\":\"1-2\"},\"children\":[{\"type\":\"button\",\"props\":{\"grid_column_gap\":\"small\",\"grid_row_gap\":\"small\",\"margin\":\"remove-vertical\",\"text_align\":\"right\"},\"children\":[{\"type\":\"button_item\",\"props\":{\"button_style\":\"\",\"content\":\"N\\u00e4chster Artikel\",\"content_en_us\":\"Next article\",\"dialog_layout\":\"modal\",\"dialog_offcanvas_flip\":true,\"icon\":\"chevron-right\",\"icon_align\":\"right\"},\"source\":{\"query\":{\"name\":\"blogs.singleNextBlog\"},\"props\":{\"link\":{\"filters\":{\"search\":\"\"},\"name\":\"link\"}}}}]}]}]},{\"type\":\"row\",\"props\":{\"margin_remove_top\":true},\"children\":[{\"type\":\"column\",\"props\":{\"image_position\":\"center-center\",\"position_sticky_breakpoint\":\"m\"},\"children\":[{\"type\":\"divider\",\"props\":{\"divider_element\":\"hr\",\"margin\":\"medium\",\"margin_remove_top\":true}}]}]}]}]},{\"type\":\"column\",\"props\":{\"image_position\":\"center-center\",\"position_sticky\":\"column\",\"position_sticky_breakpoint\":\"m\",\"position_sticky_offset\":\"120\",\"width_large\":\"1-3\"},\"children\":[{\"type\":\"headline\",\"props\":{\"block_align\":\"right\",\"block_align_breakpoint\":\"l\",\"content\":\"Neueste Artikel\",\"content_en_us\":\"Latest articles\",\"margin_remove_bottom\":false,\"maxwidth\":\"medium\",\"maxwidth_breakpoint\":\"l\",\"title_element\":\"div\",\"title_style\":\"h6\"}},{\"type\":\"grid\",\"props\":{\"block_align\":\"right\",\"block_align_breakpoint\":\"l\",\"class\":\"articles-sm\",\"content\":\"Neueste Artikel\",\"content_column_breakpoint\":\"m\",\"filter_align\":\"left\",\"filter_all\":true,\"filter_grid_breakpoint\":\"m\",\"filter_grid_width\":\"auto\",\"filter_position\":\"top\",\"filter_style\":\"tab\",\"grid_default\":\"1\",\"grid_divider\":true,\"grid_medium\":\"\",\"grid_row_gap\":\"small\",\"icon_width\":80,\"image_align\":\"top\",\"image_grid_breakpoint\":\"\",\"image_grid_width\":\"auto\",\"image_svg_color\":\"emphasis\",\"image_vertical_align\":true,\"item_animation\":true,\"lightbox_bg_close\":true,\"link_style\":\"default\",\"link_text\":\"\",\"margin\":\"default\",\"maxwidth\":\"medium\",\"maxwidth_breakpoint\":\"l\",\"meta_align\":\"above-title\",\"meta_element\":\"div\",\"meta_style\":\"text-small\",\"panel_expand\":false,\"panel_image_no_padding\":true,\"panel_link\":true,\"show_content\":true,\"show_hover_image\":true,\"show_hover_video\":true,\"show_image\":true,\"show_link\":true,\"show_meta\":true,\"show_title\":true,\"show_video\":true,\"title_align\":\"top\",\"title_element\":\"div\",\"title_font_family\":\"tertiary\",\"title_grid_breakpoint\":\"m\",\"title_grid_width\":\"1-2\",\"title_hover_style\":\"reset\",\"title_margin\":\"remove\"},\"children\":[{\"type\":\"grid_item\",\"props\":{\"yooessentials_access_conditions\":[],\"yooessentials_access_mode\":\"AND\"},\"source\":{\"query\":{\"name\":\"blogs.customBlogs\",\"arguments\":{\"users\":[],\"users_operator\":\"IN\",\"offset\":0,\"limit\":5,\"order\":\"date\",\"order_direction\":\"DESC\",\"terms\":[],\"blog_kategorie_operator\":\"IN\"}},\"props\":{\"title\":{\"filters\":{\"search\":\"\"},\"name\":\"title\"},\"meta\":{\"filters\":{\"search\":\"\"},\"name\":\"field.subline\"},\"link\":{\"filters\":{\"search\":\"\"},\"name\":\"link\"}}}}]},{\"type\":\"headline\",\"props\":{\"block_align\":\"right\",\"block_align_breakpoint\":\"l\",\"content\":\"Kategorien\",\"content_en_us\":\"Categories\",\"margin\":\"large\",\"margin_remove_bottom\":true,\"maxwidth\":\"medium\",\"maxwidth_breakpoint\":\"l\",\"title_element\":\"div\",\"title_style\":\"h6\",\"yooessentials_access_conditions\":[{\"type\":\"yooessentials_access_dynamic\",\"id\":\"ci_AD8A0F\",\"props\":{\"condition\":\"!\",\"reversed\":true},\"source_extended\":{\"props\":{\"value\":{\"name\":\"blog_kategorieString\",\"query\":{\"name\":\"#parent\"}}}}}],\"yooessentials_access_mode\":\"AND\"}},{\"type\":\"list\",\"props\":{\"block_align\":\"right\",\"block_align_breakpoint\":\"l\",\"class\":\"tag-list\",\"column_breakpoint\":\"m\",\"content\":\"Kategorien\",\"image_align\":\"left\",\"image_svg_color\":\"emphasis\",\"image_vertical_align\":true,\"list_element\":\"ul\",\"list_horizontal_separator\":\"\",\"list_type\":\"horizontal\",\"margin\":\"small\",\"maxwidth\":\"medium\",\"maxwidth_breakpoint\":\"l\",\"show_image\":true,\"show_link\":true},\"children\":[{\"type\":\"list_item\",\"source\":{\"query\":{\"name\":\"blogs.singleBlog\",\"field\":{\"name\":\"blog_kategories\",\"directives\":[{\"name\":\"slice\",\"arguments\":{\"offset\":0}}]}},\"props\":{\"content\":{\"filters\":{\"search\":\"\"},\"name\":\"name\"},\"link\":{\"filters\":{\"search\":\"\"},\"name\":\"link\"}}}}]}]}]}],\"name\":\"Blog V6\",\"source\":{\"query\":{\"name\":\"blogs.singleBlog\"}}}],\"version\":\"4.5.28\",\"yooessentialsVersion\":\"2.4.7\"} --><\/p>\n","protected":false},"featured_media":10619,"template":"","blog-kategorie":[57,45],"class_list":["post-10866","blog","type-blog","status-publish","has-post-thumbnail","hentry","blog-kategorie-data-engineering","blog-kategorie-tutorials"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.hopmann.com\/en\/wp-json\/wp\/v2\/blog\/10866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hopmann.com\/en\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.hopmann.com\/en\/wp-json\/wp\/v2\/types\/blog"}],"version-history":[{"count":0,"href":"https:\/\/www.hopmann.com\/en\/wp-json\/wp\/v2\/blog\/10866\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hopmann.com\/en\/wp-json\/wp\/v2\/media\/10619"}],"wp:attachment":[{"href":"https:\/\/www.hopmann.com\/en\/wp-json\/wp\/v2\/media?parent=10866"}],"wp:term":[{"taxonomy":"blog-kategorie","embeddable":true,"href":"https:\/\/www.hopmann.com\/en\/wp-json\/wp\/v2\/blog-kategorie?post=10866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}