# Order Channel and Marketing Code

## Script Manifest File (YML) <a href="#script-manifest-file-yml" id="script-manifest-file-yml"></a>

### Upstream Transformation Dependencies <a href="#upstream-transformation-dependencies" id="upstream-transformation-dependencies"></a>

{% hint style="warning" %}
This block is dependent on the following blocks being implemented:

* Initialization
* UOS
* Google Analytics
  {% endhint %}

### Transformation Code Requirements

The following code should be added to the main workflow in the appropriate position, after Order Status and before Daily Plan per the [Transform Code Sequence - DRP](https://help.daasity.com/technical-docs/transform-code/transform-code/transform-code-sequence-drp) page

```
  #--------------------------------------------------------------------------------------------------------------------
  # SECTION: 3000_CHANNEL AND 3400_MARKETING
  # DEPENDENCIES:
  #   - Section: 0500_UOS
  #   - Section: 2600_GA
  # OPTIONAL:
  #   - Integration: Fairing (Enquire Labs) if want to use in channel mapping
  # REQUIRED: No
  # PURPOSE: This code creates the DRP tables for order channel and should be turned on once UOS and GA are turned on
  #--------------------------------------------------------------------------------------------------------------------
  order_channel_source:
    integrations:
      - google_analytics
    scripts:
      - "github://platform-sql-shared/scripts/base/3000_channel/3010_CHN_BAS_order_channel_source.sql"

  order_channel_enquire:
    integrations:
      - enquire_labs
    scripts:
      - "github://platform-sql-shared/scripts/base/3000_channel/3015_CHN_BAS_enquire_channel_source.sql"

  order_channel_source_pt2:
    integrations:
      - google_analytics
    scripts:
      - "github://platform-sql-shared/scripts/base/3000_channel/3020_CHN_BAS_discount_code_mapping.sql"
      - "github://platform-sql-shared/scripts/base/3000_channel/3040_CHN_BAS_order_channel_influencer_discount_code.sql"
      - "github://platform-sql-shared/scripts/base/3000_channel/3050_CHN_BAS_order_channel_influencer_utm.sql"
      - "github://platform-sql-shared/scripts/base/3000_channel/3060_CHN_BAS_order_channel_source_insert.sql"

  order_channel:
    integrations:
      - google_analytics
    scripts:
      - "github://platform-sql-shared/scripts/base/3000_channel/3070_CHN_BAS_multi_channel_prep.sql"
      - "github://platform-sql-shared/scripts/base/3000_channel/3280_CHN_BAS_order_channel.sql"
      - "github://platform-sql-shared/scripts/base/3400_marketing/3410_MKT_BAS_multi_channel_transactions.sql"
```

### Order Channel and Marketing

{% hint style="success" %}
Add these scripts to build the \[`drp.order_channel`] table which provide a default Google Analytics, first-click, last-click and Daasity view of order attribution.

For those with Fairing add the Enquire Labs block to include survey based answers in the attribution
{% endhint %}

{% hint style="warning" %}
Code to support the Attribution Settings functionality is part of the Channel Attribution Data Mart and not in this section
{% endhint %}

This script creates the \[`drp.order_channel_source`] that creates one record per order for each data source of attribution and allows us to select the appropriate attribution for the Daasity view

* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3000_channel/3010_CHN_BAS_order_channel_source.sql>

Optional script to include if you have Fairing as an integration

* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3000_channel/3015_CHN_BAS_enquire_channel_source.sql>

Scripts to include different attribution methods

* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3000_channel/3020_CHN_BAS_discount_code_mapping.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3000_channel/3040_CHN_BAS_order_channel_influencer_discount_code.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3000_channel/3050_CHN_BAS_order_channel_influencer_utm.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3000_channel/3060_CHN_BAS_order_channel_source_insert.sql>
* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3000_channel/3070_CHN_BAS_multi_channel_prep.sql>

Script to populate the final \[`drp.order_channel`] table

* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3000_channel/3280_CHN_BAS_order_channel.sql>

Optional script to analyze multi-touch orders

* <https://github.com/Daasity/platform-sql-shared/blob/master/scripts/base/3400_marketing/3410_MKT_BAS_multi_channel_transactions.sql>
