# Change default events

With Pixel Your Shop it is possible to completely override the standard events for all pixels with your own dynamic code. This also allows special configurations and customer requirements, which are difficult or impossible to implement with conventional plugins.

{% hint style="info" %}
**Tip**

You can configure the following steps per sales channel & language individually, which ultimately gives you more flexibility during development.
{% endhint %}

### Short explanation <a href="#short-explanation" id="short-explanation"></a>

Each pixel code is dynamically generated in the frontend with Twig. Twig is a simple template language that generates the actual Javascript code for tracking in this case, which the end user of the shop finally triggers.

The advantage of Twig is that dynamic variables such as `products` can be used, which are used when generating the tracking code contain the correct product data. Due to the flexible structure, you can easily add custom lines of code or also replace complete scripts.

To edit the code, you have to click on the `gear symbol` in the opt-In & event boxes and activate the switch `Use own code` then.

![](/files/-Mj0GrqUWhPtqKTiLUKu)

### Opt-In Variables <a href="#opt-in-variables" id="opt-in-variables"></a>

Here is a list of the Twig variables that can be used during the opt-in:

|        Pixel       |           Variable           |  Type |        Example       |
| :----------------: | :--------------------------: | :---: | :------------------: |
|     Google gtag    |  googleAnalyticsTrackingIds  | array | `['UA-xxxxxxxxx-x']` |
|     Google gtag    |    googleAdsConversionIds    | array |  `['AW-xxxxxxxxx']`  |
|     Google gtag    |       googleAnonymizeIp      |  bool |        `true`        |
| Google Tag Manager | googleTagManagerContainerIds | array |  `['GTM-xxxxxxxx']`  |
|      Facebook      |       facebookPixelIds       | array |   `['xxxxxxxxxx']`   |
|       Hotjar       |           hotjarIds          | array |    `['xxxxxxxx']`    |

### Event Variables <a href="#event-variables" id="event-variables"></a>

Here you find a list of the Twig variables listed per event:

#### Add to card <a href="#add-to-card" id="add-to-card"></a>

|  Variable  |  Type |                            Example                           |
| :--------: | :---: | :----------------------------------------------------------: |
|  products  | array | `[{ number: 'xxxxx', name: 'Burger', priceNet: 9.99, ... }]` |
| totalPrice |  int  |                            `9.99`                            |

#### Begin checkout <a href="#begin-checkout" id="begin-checkout"></a>

|   Variable  |      Type      |                            Example                           |
| :---------: | :------------: | :----------------------------------------------------------: |
| affiliation | string or null |                 `affiliateCode/campaignCode`                 |
|    coupon   | string or null |                        `christmas_10`                        |
|   products  |      array     | `[{ number: 'xxxxx', name: 'Burger', priceNet: 9.99, ... }]` |
|  totalPrice |       int      |                            `9.99`                            |

#### Click product <a href="#click-product" id="click-product"></a>

| Variable |  Type  |                           Example                          |
| :------: | :----: | :--------------------------------------------------------: |
|  product | object | `{ number: 'xxxxx', name: 'Burger', priceNet: 9.99, ... }` |

#### Login <a href="#login" id="login"></a>

| Variable |      Type      | Example |
| :------: | :------------: | :-----: |
|  method  | string or null | `Login` |

#### Purchase <a href="#purchase" id="purchase"></a>

|   Variable  |      Type      |                            Example                           |
| :---------: | :------------: | :----------------------------------------------------------: |
| orderNumber |     string     |                           `'xxxxx'`                          |
|   shipping  |       int      |                            `2.99`                            |
| affiliation | string or null |                 `affiliateCode/campaignCode`                 |
|    coupon   | string or null |                        `christmas_10`                        |
|   products  |      array     | `[{ number: 'xxxxx', name: 'Burger', priceNet: 9.99, ... }]` |
|  totalPrice |       int      |                            `9.99`                            |
|   totalTax  |       int      |                            `9.99`                            |

#### Register <a href="#register" id="register"></a>

| Variable |      Type      |  Example  |
| :------: | :------------: | :-------: |
|  method  | string or null | `'Login'` |

#### Remove from card <a href="#remove-from-card" id="remove-from-card"></a>

|  Variable  |  Type |                            Example                           |
| :--------: | :---: | :----------------------------------------------------------: |
|  products  | array | `[{ number: 'xxxxx', name: 'Burger', priceNet: 9.99, ... }]` |
| totalPrice |  int  |                            `9.99`                            |

#### Search <a href="#search" id="search"></a>

|  Variable  |  Type  |       Example      |
| :--------: | :----: | :----------------: |
| searchTerm | string | `'My search term'` |

#### View product <a href="#view-product" id="view-product"></a>

| Variable |  Type  |                           Example                          |
| :------: | :----: | :--------------------------------------------------------: |
|  product | object | `{ number: 'xxxxx', name: 'Burger', priceNet: 9.99, ... }` |

#### View product list <a href="#view-product-list" id="view-product-list"></a>

|  Variable  |  Type |                            Example                           |
| :--------: | :---: | :----------------------------------------------------------: |
|  products  | array | `[{ number: 'xxxxx', name: 'Burger', priceNet: 9.99, ... }]` |
| totalPrice |  int  |                            `9.99`                            |

#### View product search <a href="#view-product-search" id="view-product-search"></a>

|  Variable  |  Type  |                            Example                           |
| :--------: | :----: | :----------------------------------------------------------: |
|  products  |  array | `[{ number: 'xxxxx', name: 'Burger', priceNet: 9.99, ... }]` |
| totalPrice |   int  |                            `9.99`                            |
| searchTerm | string |                      `'My search term'`                      |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shop-studio.io/shopware/extensions/pixelyourshop/development/change-default-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
