---
title: "useCampaign"
description: "useCampaign, auto-imported in the app: its options, return value and types."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/use-campaign"
---
# useCampaign

Version: nuxt-backend 0.6.x · Tab: Reference · Kind: reference · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

## Interfaces

### UseCampaignReturn

Defined in: [src/runtime/vue/composables/use-campaign.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-campaign.ts)

What [useCampaign](#usecampaign) returns.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="discountcode">
        
      </a>
      
       <code>
        discountCode
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      The discount code the address carries (<code>
        ?discount=
      </code>
      
       or the provider's own <code>
        ?discount_code=
      </code>
      
      ), when it could be a code at all. The checkout applies it; a page never repeats it, and whether it is valid is the provider's to say, at checkout.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-campaign.ts" rel="nofollow">
        src/runtime/vue/composables/use-campaign.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="attribution">
        
      </a>
      
       <code>
        attribution
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<a href="https://nuxt-backend.dev/docs/reference/api/use-billing#campaignattribution">
        <code>
          CampaignAttribution
        </code>
      </a>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      The address's <code>
        utm_*
      </code>
      
       parameters, trimmed, or <code>
        undefined
      </code>
      
       without any.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-campaign.ts" rel="nofollow">
        src/runtime/vue/composables/use-campaign.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="checkoutoptions">
        
      </a>
      
       <code>
        checkoutOptions
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        Pick
      </code>
      
      <<a href="https://nuxt-backend.dev/docs/reference/api/use-billing#checkoutoptions">
        <code>
          CheckoutOptions
        </code>
      </a>
      
      , <code>
        "discountCode"
      </code>
      
       | <code>
        "utm"
      </code>
      
      >>
    </td>
    
    <td>
      Both, as checkout options: spread them into <code>
        checkout
      </code>
      
       or <code>
        topUp
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-campaign.ts" rel="nofollow">
        src/runtime/vue/composables/use-campaign.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Functions

### useCampaign()

```ts
function useCampaign(): UseCampaignReturn;
```

Defined in: [src/runtime/vue/composables/use-campaign.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-campaign.ts)

The campaign a visitor arrived with, read from the address: a campaign
link's discount code and its UTM attribution, ready for checkout. Read
only, and nothing is stored on the device — the values live in the URL,
which the sign-in redirect keeps, so a visitor who signs in on the way
still checks out with them. The provider stores the attribution on the
order and the subscription as `utm_*` metadata.

`<PricingTable>` reads it on its own; call it for a checkout button of
your own.

#### Returns

[`UseCampaignReturn`](#usecampaignreturn)

#### Example

```vue
<script setup lang="ts">
// /pricing?discount=LAUNCH20&utm_source=newsletter
const { checkoutOptions } = useCampaign()
const { checkout } = useBilling()
</script>
<template>
  <button @click="checkout(productId, checkoutOptions)">Subscribe</button>
</template>
```


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
