# Integrate ConvertedIn Pixel using GTM

## Installation

First include the sdk in your website in the last record of the \<head> tag

````html
```js
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
    'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-P5BMX39V');</script>
    <!-- End Google Tag Manager -->
```
````

Then before the close tag of \<body>

````markup
```js
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-P5BMX39V"
    height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <!-- End Google Tag Manager (noscript) -->
```
````

### Send tracking events

All events will be sent through GTM data layer object as shown in the below table.

<table data-full-width="true"><thead><tr><th width="190.54727793696273">Event Name</th><th>Event Description</th></tr></thead><tbody><tr><td><strong>PageView</strong></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">dataLayer.push({
                'event': 'ConvertedInPageView',
                'PageView': true,
            });
</code></pre></td></tr><tr><td><strong>ViewContent</strong></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">dataLayer.push({
                'event': 'ConvertedInViewContent',
                'ViewContent': true,
                'ViewContentData': {
                    content: [
                        {
                            id: 1234, // required
                            quantity: 3, // required
                            name: "Product name", // optional
                            category: "Product Category", // optional
                        }
                    ],
                    currency: "USD", // required
                    value: 150.50 // required, sum of products price
                }
            });
</code></pre></td></tr><tr><td><strong>AddToCart</strong></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">dataLayer.push({
                'event': 'ConvertedInAddToCart',
                'AddToCart': true,
                'AddToCartData': {
                    content: [
                        {
                            id: 1234, // required
                            quantity: 3, // required
                            name: "Product name", // optional
                            category: "Product Category", // optional
                        }
                    ],
                    currency: "USD", // required
                    value: 150.50 // required, sum of products price
                }

```
        });
```

</code></pre></td></tr><tr><td><strong>InitiateCheckout</strong></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">dataLayer.push({
'event': 'ConvertedInInitiateCheckout',
'InitiateCheckout': true,
'InitiateCheckoutData': {
content: \[
{
id: 1234, // required
quantity: 3, // required
name: "Product name", // optional
category: "Product Category", // optional
}
],
currency: "USD", // required
value: 150.50 // required, sum of products price
}

```
        });
```

</code></pre></td></tr><tr><td><strong>Purchase</strong></td><td><p></p><pre class="language-javascript"><code class="lang-javascript">dataLayer.push({
'event': 'ConvertedInPurchase',
'Purchase': true,
'PurchaseData': {
content: \[
{
id: 1234, // required
quantity: 3, // required
name: "Product name", // optional
category: "Product Category", // optional
}
],
currency: "USD", // required
order\_id: 123,
value: 150.50 // required, sum of products price
}

```
        });                                
```

</code></pre></td></tr></tbody></table>

### Already Got GTM installed

Ask the team for the latest export GTM json including ( Folders, Tags, Varibles, Triggers).&#x20;

Then continue with your datalayer firing.

### Identify Customer

After login, you can assign your customer id in the local storage with a key called `ci_cid`\
\
to ensure the data integrity with the customer journey in your website.

<br>


---

# 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://developer.converted.in/pixel/integrate-convertedin-pixel-using-gtm.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.
