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

# AttributionResult

> Attribution data structure

# AttributionResult

Contains information about how the user discovered and installed your app.

```swift theme={null}
public struct AttributionResult: Sendable, Decodable, Equatable
```

## Properties

### id

```swift theme={null}
public let id: String
```

A unique identifier for this attribution record.

***

### status

```swift theme={null}
public let status: AttributionStatus
```

The attribution status. See [AttributionStatus](#attributionstatus) below.

***

### campaignId

```swift theme={null}
public let campaignId: Int?
```

The Apple Search Ads campaign ID.

<Note>
  Only available when `status` is `.attributed`.
</Note>

***

### campaignName

```swift theme={null}
public let campaignName: String?
```

The Apple Search Ads campaign name.

***

### adGroupId

```swift theme={null}
public let adGroupId: Int?
```

The ad group ID within the campaign.

***

### adGroupName

```swift theme={null}
public let adGroupName: String?
```

The ad group name.

***

### keywordId

```swift theme={null}
public let keywordId: Int?
```

The keyword ID that triggered the ad.

***

### keyword

```swift theme={null}
public let keyword: String?
```

The keyword text that the user searched for.

***

### countryOrRegion

```swift theme={null}
public let countryOrRegion: String?
```

The two-letter country or region code (ISO 3166-1 alpha-2).

**Examples:** `"US"`, `"GB"`, `"JP"`, `"DE"`

***

### clickDate

```swift theme={null}
public let clickDate: Date?
```

The date and time when the user clicked the ad.

<Note>
  Only available when the user has opted into tracking.
</Note>

***

### conversionType

```swift theme={null}
public let conversionType: String?
```

The type of conversion.

| Value          | Description |
| -------------- | ----------- |
| `"Download"`   | New install |
| `"Redownload"` | Reinstall   |

***

### supplyPlacement

```swift theme={null}
public let supplyPlacement: String?
```

The ad placement where the user saw the ad.

| Value              | Description                              |
| ------------------ | ---------------------------------------- |
| `"top_of_search"`  | Top position in App Store search results |
| `"search_results"` | Other positions in search results        |

***

## Usage Example

```swift theme={null}
let attribution = try await SpendOwl.attribution()

switch attribution.status {
case .attributed:
    print("Campaign: \(attribution.campaignName ?? "unknown")")
    print("Ad Group: \(attribution.adGroupName ?? "unknown")")
    print("Keyword: \(attribution.keyword ?? "unknown")")
    print("Country: \(attribution.countryOrRegion ?? "unknown")")

    if let clickDate = attribution.clickDate {
        print("Clicked: \(clickDate)")
    }

case .organic:
    print("User found the app organically")

case .unknown:
    print("Attribution data not yet available")
}
```

***

# AttributionStatus

The attribution status indicating how the user acquired the app.

```swift theme={null}
public enum AttributionStatus: String, Sendable, Decodable
```

## Cases

### attributed

```swift theme={null}
case attributed
```

The user installed the app after clicking an Apple Search Ads advertisement.

When attributed, the `AttributionResult` contains campaign, ad group, and keyword data.

***

### organic

```swift theme={null}
case organic
```

The user found and installed the app organically (not through ads).

Organic installs don't have campaign or keyword data.

***

### unknown

```swift theme={null}
case unknown
```

The attribution status could not be determined.

**Possible reasons:**

* Attribution data is still being processed
* The device doesn't support attribution
* An error occurred during attribution lookup

***

## Usage Example

```swift theme={null}
let attribution = try await SpendOwl.attribution()

switch attribution.status {
case .attributed:
    // Paid user - show premium onboarding
    showPremiumOnboarding()

case .organic:
    // Organic user - show standard onboarding
    showStandardOnboarding()

case .unknown:
    // Can't determine - use default
    showStandardOnboarding()
}
```

## Status Comparison

| Status        | Campaign Data | Keyword Data | Typical Scenario                   |
| ------------- | ------------- | ------------ | ---------------------------------- |
| `.attributed` | Available     | Available    | User clicked an ad                 |
| `.organic`    | `nil`         | `nil`        | User found app in App Store        |
| `.unknown`    | `nil`         | `nil`        | Attribution pending or unavailable |

## Related

<CardGroup cols={2}>
  <Card title="Attribution Guide" icon="bullseye" href="/sdk/attribution">
    Learn about attribution
  </Card>

  <Card title="SpendOwlError" icon="circle-exclamation" href="/api-reference/errors">
    Error handling
  </Card>
</CardGroup>
