> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codeqr.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Learn how to track conversion analytics with CodeQR.

<Note>
  Conversion tracking require a [Business plan](https://codeqr.iopricing)
  subscription or higher.
</Note>

[CodeQR Conversions](https://codeqr.io/help/article/codeqr-conversions) is a powerful tool that lets you turn any [short link you create on CodeQR](https://codeqr.io/help/article/how-to-create-link) into a full attribution engine. This allows you to understand how well your links are translating to actual users and revenue dollars.

<Frame>
  <img src="https://assets.codeqr.ioblog/introducing-codeqr-conversions.webp" alt="Conversion analytics" />
</Frame>

In this guide, we'll walk you through the steps to get started with CodeQR Conversions:

1. [Enable conversion tracking for your links](#step-1-enable-conversion-tracking-for-your-links)
2. [Install the `@codeqr/analytics` client-side SDK](#step-2-install-the-codeqr-analytics-client-side-sdk)
3. [Install the CodeQR server-side SDK + track conversion events](#step-3-install-the-codeqr-server-side-sdk-track-conversion-events)
4. [View your conversions](#step-4-view-your-conversions)

## Step 1: Enable conversion tracking for your links

First, you'll need to enable conversion tracking for your CodeQR links to be able to start tracking conversions.

There are a few ways to do this:

<AccordionGroup>
  <Accordion title="Option 1: On a project-level">
    To enable conversion tracking for all future links in a project, you can do the following:
    To enable conversion tracking for all future links in a project, you can do the following:

    1. Navigate to your [project's Analytics settings page](https://app.codeqr.iosettings/analytics).
    2. Toggle the **Project-level Conversion Tracking** switch to enable conversion tracking for the project.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/codeqr/images/conversions/enable-conversion-tracking-project.png" alt="Enabling conversion tracking for a project" />
    </Frame>

    This option will enable conversion tracking in the [CodeQR Link Builder](https://codeqr.io/help/article/codeqr-link-builder) for all future links.
  </Accordion>

  <Accordion title="Option 2: On a link-level">
    If you don't want to enable conversion tracking for all your links in a project, you can also opt to enable it on a link-level.

    To enable conversion tracking for a specific link, open the [CodeQR Link Builder](https://codeqr.io/help/article/codeqr-link-builder) for a link and toggle the **Conversion Tracking** switch.

    <Frame>
      <img src="https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/conversions/enable-conversion-tracking.png?fit=max&auto=format&n=Dit-PkrrSHQLOViA&q=85&s=1503a8085befc59e2ed30037d50f5ba3" alt="Enabling conversion tracking for a link" width="2345" height="908" data-path="images/conversions/enable-conversion-tracking.png" />
    </Frame>

    <Tip>
      You can also use the `C` keyboard shortcut when inside the link builder to
      quickly enable conversion tracking for a given link.
    </Tip>
  </Accordion>

  <Accordion title="Option 3: Via the API">
    Alternatively, you can also enable conversion tracking programmatically via the [CodeQR API](/api-reference/introduction). All you need to do is pass `trackConversion: true` when creating or updating a link:

    <CodeGroup>
      ```javascript Node.js theme={null}
      const link = await codeqr.links.create({
        url: "https://codeqr.io",
        trackConversion: true,
      });
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

## Step 2: Install the `@codeqr/analytics` client-side SDK

Next, you'll need to install the [@codeqr/analytics client-side SDK](/sdks/client-side/introduction).

This script detects the `cq_id` query parameter and storing it as a first-party cookie, which will be used to attribute subsequent conversion events to the original link.

<Frame>
  <img className="rounded-lg border border-gray-100" src="https://assets.codeqr.io/help/conversion-click-event.png" alt="A diagram showing how click events are tracked in the conversion funnel" />
</Frame>

You can install the `@codeqr/analytics` script in several different ways:

<CardGroup>
  <Card title="React" icon="react" href="https://docs.codeqr.io/sdks/client-side/installation-guides/react">
    Add CodeQR Analytics to your React app
  </Card>

  <Card title="Manual installation" icon="browser" href="https://docs.codeqr.io/sdks/client-side/installation-guides/manual">
    Add CodeQR Analytics to your website
  </Card>

  <Card
    title="Framer"
    icon={
  <svg
    width="74"
    height="111"
    viewBox="0 0 74 111"
    fill="none"
    xmlns="http://www.w3.org/2000/svg"
    className="w-7 h-7"
  >
    <path d="M0 0H73.8374V36.9892H36.9187L0 0Z" fill="#eb5611" />
    <path d="M0 36.989H36.9187L73.8374 73.9796H0V36.989Z" fill="#eb5611" />
    <path d="M0 73.9797H36.9187V110.97L0 73.9797Z" fill="#eb5611" />
  </svg>
}
    href="https://docs.codeqr.io/sdks/client-side/installation-guides/framer"
  >
    Add CodeQR Analytics to your Framer site
  </Card>

  <Card title="WordPress" icon="wordpress" href="https://docs.codeqr.io/sdks/client-side/installation-guides/wordpress">
    Add CodeQR Analytics to your WP site
  </Card>

  <Card title="Webflow" icon="webflow" href="https://docs.codeqr.io/sdks/client-side/installation-guides/webflow">
    Add CodeQR Analytics to your Webflow site
  </Card>
</CardGroup>

<Check>
  You can **verify the installation** with the following tests:

  1. Open the browser console and type in `_CodeQRAnalytics` – if the script is installed correctly, you should see the `_CodeQRAnalytics` object in the console.
  2. Add the `?cq_id=test` query parameter to your website URL and make sure that the `cq_id` cookie is being set in your browser.

  If both of these checks pass, the script is installed correctly. Otherwise, please make sure:

  * The analytics script was added to the `<head>` section of the page
  * If you're using a content delivery network (CDN), make sure to purge any cached content
</Check>

## Step 3: Install the CodeQR server-side SDK + track conversion events

<Tip>
  If you are using Shopify, you can skip this step since our Shopify app will
  automatically track conversions for you. Read the [Shopify integration
  guide](https://docs.codeqr.io/conversions/sales/shopify) for more information.
</Tip>

CodeQR uses server-side event tracking to track conversions, which is more reliable than client-side tracking. Depending on which framework you're using, you can use our [native SDKs](/sdks/overview):

<CardGroup>
  <Card title="TypeScript" icon="npm" href="/sdks/typescript" horizontal>
    TypeScript library for the CodeQR API
  </Card>
</CardGroup>

If you're using a framework that isn't listed, you can use the CodeQR REST API to track events on the server-side:

* [`POST /track/lead`](https://docs.codeqr.io/api-reference/endpoint/track-lead)
* [`POST /track/sale`](https://docs.codeqr.io/api-reference/endpoint/track-sale)

Once you install the SDKs, you can start tracking conversion events.

### Tracking lead events

The first event you'll want to track is a `lead` event. This happens when a user performs an action that indicates interest in your product or service. This could be anything from:

* Signing up for an account
* Adding a product to cart
* Joining a mailing list

<Frame>
  <img className="rounded-lg border border-gray-100" src="https://assets.codeqr.io/help/conversion-lead-event.png" alt="A diagram showing how lead events are tracked in the conversion funnel" />
</Frame>

Our most common lead event is `Sign Up`, which happens when a user signs up for an account. Depending on which authentication framework you're using, here are a few examples of how to send `Sign Up` lead events:

<CardGroup>
  <Card title="Clerk" icon="shield-halved" iconType="solid" href="https://docs.codeqr.io/conversions/leads/clerk" horizontal />

  <Card title="NextAuth.js" icon="shield-halved" iconType="solid" href="https://docs.codeqr.io/conversions/leads/next-auth" horizontal />

  <Card title="Supabase" icon="shield-halved" iconType="solid" href="https://docs.codeqr.io/conversions/leads/supabase" horizontal />

  <Card title="Auth0" icon="shield-halved" iconType="solid" href="https://docs.codeqr.io/conversions/leads/auth0" horizontal />

  <Card title="Appwrite" icon="shield-halved" iconType="solid" href="https://docs.codeqr.io/conversions/leads/appwrite" horizontal />
</CardGroup>

The lead event will serve as the source of truth for the customer's identity and which link they came from. This means that all subsequent actions performed by the customer (e.g. upgrading their plan, purchasing a product) will automatically be attributed to the original link.

To learn more about tracking lead events with CodeQR, refer to the following resources:

<CardGroup cols={2}>
  <Card title="Tracking lead events" icon="book-open" href="https://docs.codeqr.io/conversions/leads/introduction">
    Read the full guide on tracking lead events with CodeQR
  </Card>

  <Card title="POST /track/lead endpoint" icon="code" href="https://docs.codeqr.io/api-reference/endpoint/track-lead">
    View the full list of attributes you can pass when sending a lead event
  </Card>
</CardGroup>

### Tracking sale events

The second event you'll want to send is a `sale` event. This happens when a user purchases your product or service. This could be anything from:

* Subscribing to a paid plan
* Usage expansion (upgrading from one plan to another)
* Purchasing a product

<Frame>
  <img className="rounded-lg border border-gray-100" src="https://assets.codeqr.io/help/conversion-sale-event.png" alt="A diagram showing how sale events are tracked in the conversion funnel" />
</Frame>

Depending on which payment processor you're using, we offer native integrations for the following:

<CardGroup cols={2}>
  <Card title="Stripe" icon="stripe" href="https://docs.codeqr.io/conversions/sales/stripe" horizontal />

  <Card title="Shopify" icon="shopify" href="https://docs.codeqr.io/conversions/sales/shopify" horizontal />
</CardGroup>

Alternatively, you can also send sale events manually using [our SDKs](/sdks/overview) or the [`POST /track/sale` API endpoint](https://docs.codeqr.io/api-reference/endpoint/track-sale).

To learn more about tracking sale events with CodeQR, refer to the following resources:

<CardGroup cols={2}>
  <Card title="Tracking sale events" icon="book-open" href="https://docs.codeqr.io/conversions/sales/introduction">
    Read the full guide on tracking sale events with CodeQR
  </Card>

  <Card title="POST /track/sale endpoint" icon="code" href="https://docs.codeqr.io/api-reference/endpoint/track-sale">
    View the full list of attributes you can pass when sending a sale event
  </Card>
</CardGroup>

## Step 4: View your conversions

Once you've enabled conversion tracking for your links, all your tracked conversions will show up on your [Analytics dashboard](https://app.codeqr.ioanalytics). We provide 3 different views to help you understand your conversions:

* **Time-series**: A [time-series view](https://codeqr.io/help/article/codeqr-analytics#1-time-series-analytics-chart) of the number clicks, leads and sales.

<Frame>
  <img src="https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/conversions/timeseries-chart.png?fit=max&auto=format&n=Dit-PkrrSHQLOViA&q=85&s=c7bac376603cd71f967f5f7b33f3cadc" alt="Time-series line chart" width="1600" height="900" data-path="images/conversions/timeseries-chart.png" />
</Frame>

* **Funnel chart**: A funnel chart view visualizing the conversion & dropoff rates across the different steps in the conversion funnel (clicks → leads → sales).

<Frame>
  <img src="https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/conversions/funnel-chart.png?fit=max&auto=format&n=Dit-PkrrSHQLOViA&q=85&s=001b9b2dad0f759c4031d81122069a75" alt="Funnel chart view showing the conversion & dropoff rates from clicks → leads → sales" width="1600" height="900" data-path="images/conversions/funnel-chart.png" />
</Frame>

* **Real-time events stream**: A [real-time events stream](https://codeqr.io/help/article/real-time-events-stream) of every single conversion event that occurs across all your links in your project.

<Frame>
  <img src="https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/conversions/events-table.png?fit=max&auto=format&n=Dit-PkrrSHQLOViA&q=85&s=93b55a350e472e6d7fbafa7e082bbc69" alt="The Events Stream dashboard on CodeQR" width="1600" height="900" data-path="images/conversions/events-table.png" />
</Frame>

## Example Apps

<CardGroup cols={2}>
  <Card title="CodeQR Conversions Demo App" icon="github" href="https://github.com/codeqr-io/examples/tree/main/conversions/stripe" color="#333333">
    See the full example on GitHub.
  </Card>
</CardGroup>
