# advanced\_attribution

<a href="https://dbdiagram.io/e/67bf2e04263d6cf9a08d27a6/67c08ae8263d6cf9a0b33078" class="button primary" data-icon="table-tree">Prebuilt reports and definition</a>

***

## <mark style="background-color:purple;">Syncing</mark>

The advanced attribution table is a view.

{% file src="<https://1847929239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoRN0sxIyI0UJdSqkwdBu%2Fuploads%2Fo6ld8p9zAQoFsKQJ5BlN%2Fraw_conversions.sql?alt=media&token=b2472536-6967-4d28-af2a-23e82e0665a0>" %}

***

## Description

### Technical Definition of a conversion

From a technical perspective for Quanti, a conversion is a hit where the value of the `conversion_id` parameter is not `null`, `undefined`, or *empty*. One of these conditions must be satisfied to add a new row in the advanced attribution table.

### Primary keys explanations

The advanced attribution table's primary keys are `hit_id` and `s_session_id` :

* We have made the decision to insert a field named `hit_id` into the table, which precisely identifies the hit that registered the conversion from `raw_hits`. This ensures the table's integrity by addressing a potential issue with the uniqueness of `conversion_id`. `hit_id` is technically more precise than the `conversion_id`.
* The `s_session_id` is the second primary key of the table and allows linking a session to a conversion. Multiple sessions can participate in the same conversion, and the same session can participate in multiple conversions.

In this table, a single `conversion_id` can be used across multiple rows because it may have been generated by a series of sessions (One row in the table = one session for a given conversion). Similarly, a `session_id` can also be used on multiple rows because it might have originated several conversions. However, what is essentially maintained is the presence of a unique `session_id` per conversion.

### Attibution rules

We have 2 ways to catch up on sessions and assess their contribution to achieving a conversion :

* By **visitor\_id** : We log all previous sessions that have the same `visitor_id` as the session during which the conversion occurred.
* By **user\_id** : We log all previous sessions that have the same `user_id` as the session during which the conversion occurred.

The values `null`, `undefined`, or *empty* for `visitor_id` and `user_id` are obviously excluded from the attribution calculation rules.

### The paths

Now that you've understood that the table consists of a list of sessions that contributed to achieving conversion(s), it's crucial to know how you can distinguish them from a chronological perspective and especially how you are going to analyze the paths taken by your visitors and calculate the contribution of each session. There is evidently the "s\_datetime" field which gives the exact date and time of the session's start, but we have made the task easier for you by implementing two fields:

* `max_index`: Indicates the total number of contributive sessions related to a conversion. The value of this field is the same for each session (row) for a given conversion.
* `path_index`: indicates the chronological position of the session among all the contributory sessions leading to a conversion.

For a conversion tracking multiple contributive sessions, you will therefore have in `path_index` numbers ranging from 1 to the number representing the total number of sessions. Then, on each line in `max_index`, you will find the maximum number that represents the total number of sessions.

<figure><img src="https://1847929239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoRN0sxIyI0UJdSqkwdBu%2Fuploads%2FjFSMzGgGDbE67GilHqzL%2FBigQuery-%E2%80%93-Quanti-%E2%80%93-Console-Google-Cloud.png?alt=media&#x26;token=0202d23b-4291-479c-ae93-0264a849e1d0" alt="Example of filling in the path_index and max_index fields"><figcaption><p>Example of filling in the <code>path_index</code> and <code>max_index</code> fields</p></figcaption></figure>

## <mark style="background-color:purple;">Fields definition</mark>

### hit\_id

**Unique hit identifier** automatically created by Quanti: which **registering** the conversion.

### s\_session\_id

**Unique session identifier** automatically created by Quanti: which linked the conversion.

{% hint style="info" %}
Learn more about [session\_id](https://docs.quanti.io/tag-tracker/raw_sessions#session_id).
{% endhint %}

### s\_visitor\_id

**Unique visitor identifier** automatically created by Quanti: which linked the conversion.

{% hint style="info" %}
Learn more about [visitor\_id](https://docs.quanti.io/tag-tracker/raw_sessions#visitor_id).
{% endhint %}

### c\_user\_id

**Unique user identifier** from the client / contact base which linked the conversion.

### c\_conversion\_id

**Unique conversion identifier** from the client generated by the site and specify in the tag.

### c\_conversion\_type

The type of the conversion generated by the site and specify in the tag.

### c\_conversion\_value

Monetary value of the conversion generated by the site and specify in the tag.

### c\_date

DATE type field indicating the generation date of the conversion.

### c\_datetime

DATETIME type field indicating the generation date of the conversion.

### s\_date

DATE type field indicating the date of the session.

### s\_source

The s\_source field is the value of **utm\_source** parameter of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_source](https://docs.quanti.io/tag-tracker/raw_sessions#s_source).
{% endhint %}

### s\_medium

The s\_medium field is the value of **utm\_medium** parameter of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_medium](https://docs.quanti.io/tag-tracker/raw_sessions#s_medium).
{% endhint %}

### s\_campaign

The s\_campaign field is the value of **utm\_campaign** parameter of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_campaign](https://docs.quanti.io/tag-tracker/raw_sessions#s_campaign).
{% endhint %}

### s\_content

The s\_content field is the value of **utm\_content** parameter of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_content](https://docs.quanti.io/tag-tracker/raw_sessions#s_content).
{% endhint %}

### s\_keyword

The s\_keyword field is the value of **utm\_term** parameter of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_keyword](https://docs.quanti.io/tag-tracker/raw_sessions#s_keyword).
{% endhint %}

### s\_utm\_id

The s\_utm\_id field is the value of **utm\_id** parameter of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_utm\_id](https://docs.quanti.io/tag-tracker/raw_sessions#s_utm_id).
{% endhint %}

### s\_consent

The s\_consent field is the value of **s\_consent** field of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_consent](https://docs.quanti.io/tag-tracker/raw_sessions#s_consent).
{% endhint %}

### s\_referrer

The s\_referrer field is the value of **s\_referrer** field of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_referrer](https://docs.quanti.io/tag-tracker/raw_sessions#s_referrer).
{% endhint %}

### s\_ad\_user\_data

The s\_ad\_user\_data field is the value of **s\_ad\_user\_data** field of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_ad\_user\_data](#s_ad_user_data).
{% endhint %}

### s\_ad\_personalization

The s\_ad\_personalization field is the value of **s\_ad\_personalization** field of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_ad\_personalization](#s_ad_personalization).
{% endhint %}

### s\_ad\_storage

The s\_ad\_storage field is the value of **s\_ad\_storage** field of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_ad\_storage](#s_ad_storage).
{% endhint %}

### s\_analytics\_storage

The s\_analytics\_storage field is the value of **s\_analytics\_storage** field of the session arose from `raw_sessions` table.

{% hint style="info" %}
Learn more about [s\_analytics\_storage](#s_analytics_storage).
{% endhint %}

### path\_index

Chronological position of the session among all the contributory sessions leading to a conversion.\
The value "1" represents the session that is the furthest away chronologically from the conversion. The session closest to the conversion (being the one during which the conversion took place) will have the highest number and will be equal to the value of the field `max_index` defined below.

### max\_index

The total number of contributive sessions related to the conversion (define by hit\_id value). The value of this field is the same for each session (row) for a given conversion.

### lookback\_window

The total number of days between the conversion date and the session date.

### is\_last\_clic

Boolean field indicating if the session (the row) is the session that led to the conversion. Technically, this is the session for which `path_index` = `max_index`.

### is\_last\_clic\_non\_direct

Boolean field indicating if the session (the row) is the session that led to the conversion after excluding all sessions with a s\_source value `(direct)` and a s\_medium value `(none)`. Technically, this is the session for which `path_index` is the highest (After excluding (Direct) sources).\
If the conversion is carried out in a single session with s\_source value `(direct)` and a s\_medium value `(none)`, then this single session is considered as the LCND.\
If the conversion is conducted through multiple sessions but all of them have the s\_source value `(direct)` and the s\_medium value `(none)`, then the most recent one of these is considered the LCND.

### is\_post\_clic\_30

Boolean field indicating if the session (the row) occurred within the 30 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date`.

### is\_post\_clic\_60

Boolean field indicating if the session (the row) occurred within the 60 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date`.

### is\_post\_clic\_90

Boolean field indicating if the session (the row) occurred within the 90 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date`.

### is\_post\_clic\_120

Boolean field indicating if the session (the row) occurred within the 120 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date`.

### is\_post\_clic\_180

Boolean field indicating if the session (the row) occurred within the 180 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date`.

### is\_first\_clic\_30

Boolean field indicating if the earliest session of the path is occurred within the 30 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date` and it concern only session with a path\_index = 1.

### is\_first\_clic\_60

Boolean field indicating if the earliest session of the path is occurred within the 60 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date` and it concern only session with a path\_index = 1.

### is\_first\_clic\_90

Boolean field indicating if the earliest session of the path is occurred within the 90 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date` and it concern only session with a path\_index = 1.

### is\_first\_clic\_120

Boolean field indicating if the earliest session of the path is occurred within the 120 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date` and it concern only session with a path\_index = 1.

### is\_first\_clic\_180

Boolean field indicating if the earliest session of the path is occurred within the 180 days preceding the conversion. Technically, this is the difference between `s_date` and `c_date` and it concern only session with a path\_index = 1.
