# Tracking with UTT: JavaScript Functions

Read more about [tracking with UTT](https://help.impact.com/brand/platform-features/tracking/javascript-tag-tracking/tracking-with-universal-tracking-tag-utt).

#### `identify` function

The `identify` function is used to identify users accurately across your site, particularly across devices. Supply identifiers so impact.com can map users to conversion events for attribution. You can learn more about [installing the identify function here](https://integrations.impact.com/impact-brand/docs/javascript-installation#step-2-install-the-identify-function).

```programlisting
<script type="text/javascript">
  ire('identify', {
    customerId: 'Customer Id',
    customerEmail: 'SHA1 Email Address',
    customProfileId: 'UUID'
  });
</script>
```

{% hint style="info" %}
**Note:** The `customerId`, `customerEmail` , and `customProfileId` values should be dynamically populated on your site if a user is logged in, or left blank if they cannot be populated.
{% endhint %}

#### `generateClickId` function (Direct Tracking)

The `generateClickId` function can be used to obtain the impact.com `clickId` value whenever accessing the `clickId` value from the landing page URL’s query string parameters is not possible.

```programlisting
<script type="text/javascript">
  ire('generateClickId', function(clickId) {
    // use clickId here
  });
</script>
```

{% hint style="info" %}
**Direct Tracking Example**

```programlisting
<script type="text/javascript">
  ire('generateClickId', function(clickId) {
    var myClickId = clickId;
    alert(myClickId);
  });
</script>
```

{% endhint %}

#### `trackCart` function (Last to Cart crediting)

Last to Cart is similar to Last Click crediting in that one of the last steps a customer takes in the conversion path will determine which partner receives all the credit and payout for the conversion.

With Last to Cart crediting, the last time a customer adds an item to their cart will determine the winning partner. Implementing the `trackCart` function is required to support usage of the Last to Cart credit policy. See [Last to Cart Credit Policy Explained](https://help.impact.com/brand/platform-features/tracking/credit-policies/last-to-cart-credit-policy-explained) for more details.

Add this function to the **Add to Cart** button.

```programlisting
<script type="text/javascript">
  ire('trackCart', [event_id], {customProfileId: 'UUID'});
</script>
```

{% hint style="info" %}
**Note:** The Event Type ID must be your tracker-specific ID found under **Tracking Settings** → **Event Types**. The parameters should be dynamically populated with values from the conversion.
{% endhint %}

#### Conversion Pixel

<details>

<summary>Lead Tracker Example</summary>

```programlisting
<script type="text/javascript">
  ire('trackConversion', ACTIONTRACKERID, {
    orderId: "Your Order Id here",
    customProfileId: "Your Custom Profile Id here",
    customerId: "Your Customer Id here",
    customerEmail: "Your Customer Email here",
    customerStatus: "A Status here",
    orderPromoCode: "Your Promo Code here"
  }, {
    verifySiteDefinitionMatch: true
  });
</script>
```

</details>

<details>

<summary>Sale Tracker Example</summary>

```programlisting
<script type="text/javascript">
  ire('trackConversion',
    ACTIONTRACKERID, {
      orderId: "Your Order Id here",
      customProfileId: "Your Custom Profile Id here",
      customerId: "Your Customer Id here",
      customerEmail: "Your Customer Email here",
      customerStatus: "A Status here",
      orderPromoCode: "Your Promo Code here",
      currencyCode: "USD",
      items: [{
        subTotal: 100.00,
        category: "Category here",
        sku: "SKU here",
        quantity: 2
      }, {
        subTotal: 50.00,
        category: "Category here",
        sku: "SKU here",
        quantity: 1
      }]
    }, {
      verifySiteDefinitionMatch: true
    }
  );
</script>
```

</details>
