X Enterprises
nuxt-x-affiliate

Affiliate Link

Slot-based affiliate link when you need full visual control over the CTA — still gets tagging, click events, and FTC-compliant rel attributes.

Affiliate Link

The XAFAffiliateLink component is the slot-based sibling of XAFBuyButton. When XAFBuyButton is too opinionated about layout, use this — you bring the visual; the component handles merchant tag injection, click events, and FTC-compliant rel attributes.

Components

<XAFAffiliateLink merchant="amazon" url="https://amazon.com/dp/X">
  <template #default="{ merchant, tagged }">
    <button :class="['cta', { 'cta--tagged': tagged }]">
      Check price on {{ merchant.displayName }}
    </button>
  </template>
</XAFAffiliateLink>

Props

PropTypeDefaultDescription
merchantMerchantIdrequiredMerchant to tag for. Resolved via useAffiliateContent().getMerchant().
urlstringrequiredOutbound URL. Will be tagged with the merchant's tagValue if configured.
tostringRender as <NuxtLink> if internal route.
disabledbooleanfalseRender as a non-interactive span instead of an anchor.
newTabbooleantrueOpen in a new tab.

Slot props

PropTypeDescription
merchantXAffiliateContentMerchantThe full resolved merchant config (displayName, ctaLabel, color, etc.).
merchantIdMerchantIdThe merchant ID you passed in.
taggedbooleantrue if the URL already carried a tag when passed in. Useful for visual differentiation (e.g. dimming a "tagged" link).

Events

EventPayloadDescription
click{ url, merchant, originalUrl }Fired on click. originalUrl is the URL before tag injection.
navigate{ url }Fired on click when to is set (internal navigation).

Click tracking

Calls useAffiliateContent().trackClick({ ... }) which pushes affiliate_click to window.dataLayer when GTM is loaded (noop otherwise).

Examples

Custom-styled CTA button

<XAFAffiliateLink merchant="amazon" url="https://amazon.com/dp/B0CX123">
  <template #default="{ merchant }">
    <button class="cta-btn">
      <Icon name="i-mdi-cart" /> Buy on {{ merchant.displayName }}
    </button>
  </template>
</XAFAffiliateLink>
<XAFAffiliateLink :merchant="'amazon'" :url="link.url">
  <template #default="{ tagged }">
    <span :class="{ 'opacity-50': tagged }">
      {{ tagged ? 'Already tagged' : 'Visit' }}
    </span>
  </template>
</XAFAffiliateLink>

AI Context

component: XAFAffiliateLink
package: "@xenterprises/nuxt-x-affiliate"
use-when: >
  You need an affiliate link with full visual control over the CTA —
  XAFBuyButton is too opinionated. XAFAffiliateLink wraps any child
  element with merchant tag injection, click tracking, and FTC-compliant
  rel="sponsored noopener noreferrer". Resolves merchant config via
  useAffiliateContent(). Slot exposes { merchant, merchantId, tagged }
  so you can vary rendering by tag presence.
Copyright © 2026