> For the complete documentation index, see [llms.txt](https://docs.firework.com/firework-for-developers/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking.md).

# Tracking

{% hint style="info" %}
If you are using any of Firework e-commerce app/extension/cartridge (like Shopify, Magento, SFCC etc.), you do not need to implement the purchase tracking manually. It is handled by the app/extension/cartridge. Please refer to the purchase tracking section of the e-commerce platform integration doc for more details.
{% endhint %}

Firework provides a way to attribute tracking events, such as "purchase", with additional properties like value and products

### Embed Analytics Script Tag

Make sure the Firework script is injected into `<header>` at all your pages where you want to call the tracking function. Usually, it's the header of the checkout page.

```
<script async type="text/javascript" src="//asset.fwcdn3.com/js/analytics.js"></script>
```

Call the relevant push event whenever it is needed.

### Tracking events

Below are the list of tracking events Firework support

<table><thead><tr><th width="147">Type</th><th width="412">Method</th><th>Description</th></tr></thead><tbody><tr><td>Purchase</td><td><code>window._fwn.analytics.purchase()</code></td><td><a href="https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/purchase">https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/purchase</a></td></tr><tr><td>Add to cart</td><td><code>window._fwn.analytics.addToCart()</code></td><td><a href="https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/add-to-cart">https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/add-to-cart</a></td></tr><tr><td>Remove from cart</td><td><code>window._fwn.analytics.removeFromCart()</code></td><td><a href="https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/remove-from-cart">https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/remove-from-cart</a></td></tr><tr><td>Page viewed</td><td><code>window._fwn.analytics.pageViewed()</code></td><td><a href="https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/page-viewed">https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking/page-viewed</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.firework.com/firework-for-developers/web/integration-guide/shopping-integration-v2/tracking.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
