Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the topic Setting up GA4 for A/B testing to the How do I create and track an A/B test? section #383

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/developing-capabilities/apps/ab-test/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Let's explore each step:
- Editing your variant
- Creating events and collecting data
- Funnel and results
- GA4 Setup for A/B Testing

## Creating an Experiment

Expand Down Expand Up @@ -118,3 +119,36 @@ Data is transferred in real-time, no more waiting a day or two to analyze them.
![Experiments screen](https://ozksgdmyrqcxcwhnbepg.supabase.co/storage/v1/object/public/assets/530/6ddc740d-9590-431b-b1e7-f0a0130bc5f6)

![Experiments screen](https://ozksgdmyrqcxcwhnbepg.supabase.co/storage/v1/object/public/assets/530/cc637298-e938-494c-9253-b7d1bef6f99a)

## GA4 Setup for A/B Testing

To ensure data consistency while navigating an A/B test on deco.cx, we use a cookie called deco_segment.

This cookie lasts for 30 days by default and can be used to determine which version the user is in.

All data sent to the deco.cx Analytics is already segmented by version.

However, for this to also occur in GA4, it is necessary to check this cookie and segment the events based on that information.

- Example of cookie:
```
deco_segment=TdCJTIyYWN0aXZlJTIyJTNBJTVCJTVEJTJDJTIyaW5hY3RpdmVEcmF3biUyMiUzQSU1QiUyMlRlc3RlJTIwVGF2YW5vJTIyJTVEJTdE
```

- To extract readable data from this hash, use the following function:
```javascript
getData(myCookie) {
return JSON.parse(decodeURIComponent(atob(myCookie)))
}

```

- This will return an object like:
```json
{
active: [],
inactiveDrawn: ['Teste Tavano']
}
```

This way, in GTM, you can identify whether the user is participating in Test X, allowing for the segmented and accurate dispatch of events.
32 changes: 32 additions & 0 deletions docs/developing-capabilities/apps/ab-test/pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,35 @@ analisá-los.
![Experiments screen](https://ozksgdmyrqcxcwhnbepg.supabase.co/storage/v1/object/public/assets/530/6ddc740d-9590-431b-b1e7-f0a0130bc5f6)

![Experiments screen](https://ozksgdmyrqcxcwhnbepg.supabase.co/storage/v1/object/public/assets/530/cc637298-e938-494c-9253-b7d1bef6f99a)

## Setup do GA4 para Teste A/B

Para assegurar a consistência dos dados fornecidos fornecidos ao navegar em um Teste A/B na deco.cx, utilizamos um cookie, chamado _deco_segment_.

Esse cookie dura por padrão 30 dias e pode ser utilizado para entender em qual versão o usuário está.

Todos os dados que vão para o Analytics da deco.cx, já são separados por segmento.

Porém, para que isso também aconteça no GA4, é necessário verificar esse cookie e segmentar os eventos com base nessa informação.

- Exemplo de cookie
```
deco_segment=TdCJTIyYWN0aXZlJTIyJTNBJTVCJTVEJTJDJTIyaW5hY3RpdmVEcmF3biUyMiUzQSU1QiUyMlRlc3RlJTIwVGF2YW5vJTIyJTVEJTdE
```

- Para extrair o dado legível deste hash, utilize a função:
```javascript
getData(myCookie) {
return JSON.parse(decodeURIComponent(atob(myCookie)))
}
```

- Isso irá devolver um objeto como:
```json
{
active: [],
inactiveDrawn: ['Teste Tavano']
}
```

Dessa forma, no GTM, você consegue identificar se o usuário está participando do Teste X, permitindo o envio de eventos de forma segmentada e precisa.
Loading