# Personal Loans

## Overview

This documentation covers installation, required prerequisites, configuration properties currently surfaced (channel, zone, experience, isDev), and a basic usage example.

## Getting Started

You’ll need the correct `channel` and `zone` values for your integration. Ask your Partner Manager to provide these values for Flutter Personal Loans.

Use `isDev: true` while you test. Set `isDev: false` before releasing to production.

### Prerequisites

* Flutter 3.0.0 or higher
* Dart 3.10.7 or higher

### Installation

Add the dependency to your **pubspec.yaml**:

```yaml
dependencies: engine_mobile_flutter_sdk: ^0.0.3
```

Then install the dependency:

```bash
flutter pub get
```

## Initializing the SDK

Add the following import to any Dart file where you want to use the SDK:

```dart
import 'package:engine_mobile_flutter_sdk/engine_mobile_flutter_sdk.dart';
```

### Basic Example

Place the `EngineSDK` widget anywhere in your widget tree to render the Personal Loan flow.

```dart
EngineSDK(
  channel: 'your-channel',
  zone: 'your-zone',
  experience: 'search',
)
```

## Properties

Pass these properties to `EngineSDK`:

* `channel` (String, required)\
  Identifies your integration in Engine. **Provided by your Partner Manager.**\
  Example: `'direct'`
* `zone` (String, required)\
  Identifies the placement or distribution surface for the SDK. **Provided by your Partner Manager.**\
  Example: `'marketplace'`
* `experience` (String, required)\
  Selects the product flow variant. Use `'search'` for Personal Loans unless instructed otherwise.\
  Example: `'search'`
* `isDev` (bool, optional, default: `false`)\
  Enables development/testing mode. Keep `false` in production releases.\
  Example: `true`

## User Experience Demo

The SDK renders a complete Personal Loans journey inside your app. It collects any missing user inputs, submits the lead, and then displays offers.

Typical flow:

1. Landing screen
2. Loan and personal details form
3. Review / confirm details
4. Offer results

![Landing Screen](https://3849802388-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MeMvVDbjd8vJWZ9Hwf0%2Fuploads%2Fl5JprqX3113AZpv3I1Gi%2Fimage.png?alt=media\&token=de4c1e07-53bc-4548-93d0-1857bee09acd) ![Loan Details](https://3849802388-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MeMvVDbjd8vJWZ9Hwf0%2Fuploads%2F7bLp8KyV6xxw47txXg7X%2Fimage.png?alt=media\&token=a068a4ab-713a-48da-bc78-c3d7a2b94976)

<div><figure><img src="https://3849802388-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MeMvVDbjd8vJWZ9Hwf0%2Fuploads%2FAHEoiF6lhYWVZ2RC275v%2Fimage.png?alt=media&#x26;token=33cbd43a-b716-4fc4-aeba-4bd6f501e0f8" alt="" width="324"><figcaption><p>Personal Details</p></figcaption></figure> <figure><img src="https://3849802388-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MeMvVDbjd8vJWZ9Hwf0%2Fuploads%2F7kqlc4OPYooQ7KritqX6%2Fimage.png?alt=media&#x26;token=9bf6fc7c-6eaa-44bd-9bd0-cc1863e07e56" alt="" width="324"><figcaption><p>Personal Details</p></figcaption></figure></div>

<div align="center"><figure><img src="https://3849802388-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MeMvVDbjd8vJWZ9Hwf0%2Fuploads%2Fl2VXIBWGm0JhHPsiXmNj%2Fimage.png?alt=media&#x26;token=9856a363-e35d-42da-aa43-ba5d62109285" alt="" width="324"><figcaption><p>Personal Details</p></figcaption></figure> <figure><img src="https://3849802388-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MeMvVDbjd8vJWZ9Hwf0%2Fuploads%2FcGAMRTsWzONbqinwuZFI%2Fimage.png?alt=media&#x26;token=a41b78ff-16dd-4307-a5f2-d3ce435e7c1c" alt="" width="324"><figcaption><p>Personal Details</p></figcaption></figure></div>

## Client Tags for Reporting

The Engine Flutter SDK supports adding your unique Client Tags to track performance of specific campaigns or users. All Client Tag data is attributed to the lead level.

Client Tags can be added by including a **clientTags** attribute at the top level of the EngineSDK widget, where the value is a **Map\<String, List\<String>>**.&#x20;

We strongly recommend including only one element per list for ease of reporting and attribution—if you want two separate tags, include the second tag under a different key. There is no limit to the number of keys in the **clientTags** map

### Example

```dart
EngineSDK( 
isDev: false, 
bearerToken: '{your_token}', 
channel: '{your_channel}', 
zone: '{your_zone}', 
experience: '{your_experience}', 
prefilledData: // ...any data you don't want to ask for again 
clientTags: const { 
'clientId': ['client1'], 
'trafficsource': ['email'], 
'campaignId': ['campaign1'], 
}, 
// ...optional Event Handlers, please see Event Handler section 
)
```

**Note**: Client Tags are only sent when both prefilledData and bearerToken are provided.

### Supported Client Tag Keys for Reporting

If you plan for the Engine team to set up reporting (i.e., you do not plan to hit the Analytics API), these are the only keys that are currently fully supported. If a different key is needed, please reach out to your partner manager—we may be able to accommodate, but adding nonstandard keys will increase the time it takes Engine to report Client Tag values back to you and is therefore not recommended.

* agentId
* campaignId
* clientId
* deviceid
* medium
* sourceId
* subid
* subid1
* subid2
* subid3
* target
* trafficsource
* userid

See the [GET Lead Client Tags](https://engine.tech/docs/api-reference/#get-lead-client-tags) endpoint for information on attributing lead analytics to your own client tags, if you decide to hit the Analytics API for reporting.

## Prefilling Lead Data

This sections describes how to prefill any user data you already have into your Flutter SDK implementation.

### PrefilledData Example

Here is a full code snippet of how you might implement the Flutter SDK into your app, with all `prefilledData` fields populated:

```dart
EngineSDK( isDev: false,
 bearerToken: '{your_token}', 
 channel: '{your_channel}', 
 zone: '{your_zone}', 
 experience: '{your_experience}', 
 
 prefilledData: LeadPrefillData( 
 firstName: 'Bob', 
 lastName: 'Dylan', 
 email: 'bobdylan@gmail.com', 
 loanAmount: 7500,
 purpose: LoanPurpose.creditCardRefi,
 dateOfBirth: DateTime(1990,1,1), 
 address: const Address( 
 street: '1600 Pennsylvania Avenue', 
 city: 'Washington', 
 state: 'DC', 
 zip: '20500', 
 ), 
 
 primaryPhone: '2325624852', 
 phoneConsent: true,
 ssn: '512-54-7862', 
 creditRating: CreditRating.good,
 propertyStatus: PropertyStatus.ownWithMortgage,
 educationLevel: EducationLevel.associate,
 employmentStatus: EmploymentStatus.employedFullTime,
 annualIncome: 20000,
 hasDirectDeposit: false,
 bankRoutingNumber: '123456789', 
 bankAccountNumber: '55555555555', 
 payFrequency: 
 PayFrequency.biweekly,
 ), 
 clientTags: const { 
 'sdkVersion': ['0.0.1'],
'platform': ['flutter'], 
}, 
)
```

The prefilledData object should include any fields you want the user to not have to answer themselves, if you already have that info available. You may prefill as many of these fields as desired.

**Important**: Do not prefill any fields that are empty or otherwise unavailable. If you do not have info for a particular field, omit that field from your prefilledData object.

For example, the following is **incorrect**:

```dart
LeadPrefillData( 
firstName: 'Bob', 
lastName: 'Dylan', 
email: 'bobdylan@gmail.com', 
address: const Address(), 
// Empty Address is prefilled, which prevents the user from submitting complete info 
)
```

This is **correct**:

```dart
LeadPrefillData( 
firstName: 'Bob', 
lastName: 'Dylan', 
email: 'bobdylan@gmail.com', 
// Address is omitted, forcing the user to input their address in the UI 
)
```

### PrefilledData Type Definitions

The data should follow the class/type schema described below in Dart:

```dart
class LeadPrefillData { 
final String? firstName; 
final String? lastName; 
final String? email; 
final int? loanAmount; // whole numbers only 
final LoanPurpose? purpose; // enum below 
final DateTime? dateOfBirth; 
final Address? address; // class below 
final String? primaryPhone; // leading 1 is fine, no "+" or "-" chars 
final String? ssn; // 9 digits with or without hyphens 
final CreditRating? creditRating; // enum below
final PropertyStatus? propertyStatus; // enum below 
final EducationLevel? educationLevel; // enum below 
final EmploymentStatus? employmentStatus; // enum below 
final int? annualIncome; // raw integer value (e.g. 20000, 60000) 
final bool? phoneConsent; 
final bool? hasDirectDeposit; 
final String? bankRoutingNumber; // must be exactly 9 digits 
final String? bankAccountNumber; 
final PayFrequency? payFrequency; // enum below
```

### Enums/Accepted Values for Certain Fields

Certain fields must use one of the predefined Dart enum values. Here are those values:

```dart
class Address { 
final String? street; // primary street address 
final String? apartment; // optional apartment / suite 
final String? city; 
final String? state; // must be a valid 2-letter abbreviation 
final String? zip; 
}

enum LoanPurpose { 
LoanPurpose.debtConsolidation,
 LoanPurpose.creditCardRefi,
 LoanPurpose.homeImprovement,
 LoanPurpose.wedding,
 LoanPurpose.largePurchases,
 LoanPurpose.studentLoanRefi,
 LoanPurpose.autoPurchase,
 LoanPurpose.baby,
 LoanPurpose.boat,
 LoanPurpose.business,
 LoanPurpose.green,
 LoanPurpose.householdExpenses,
 LoanPurpose.medicalDental,
 LoanPurpose.movingRelocation,
 LoanPurpose.taxes,
 LoanPurpose.vacation,
 LoanPurpose.autoRefinance,
 LoanPurpose.studentLoan,
 LoanPurpose.carRepair,
 LoanPurpose.cosmetic,
 LoanPurpose.emergency,
 LoanPurpose.engagement,
 LoanPurpose.homePurchase,
 LoanPurpose.homeRefi,
 LoanPurpose.lifeEvent,
 LoanPurpose.motorcycle,
 LoanPurpose.rv,
 LoanPurpose.specialOccasion,
 LoanPurpose.other,
 } 

 enum CreditRating { 
 CreditRating.excellent,
 CreditRating.good,
 CreditRating.fair,
 CreditRating.poor,
 CreditRating.limited,
 } 

 enum PropertyStatus { 
 PropertyStatus.ownOutright,
 PropertyStatus.ownWithMortgage,
 PropertyStatus.rent,
 } 

 enum EducationLevel { 
 EducationLevel.highSchool,
 EducationLevel.associate,
 EducationLevel.bachelors,
 EducationLevel.masters,
 EducationLevel.doctorate,
 EducationLevel.stillEnrolled,
 } 

 enum EmploymentStatus { 
 EmploymentStatus.employedFullTime,
 EmploymentStatus.employedPartTime,
 EmploymentStatus.selfEmployed,
 EmploymentStatus.military,
 EmploymentStatus.notEmployed,
 EmploymentStatus.other,
 } 

 enum PayFrequency { 
 PayFrequency.biweekly,
 PayFrequency.monthly,
 PayFrequency.twiceMonthly,
 PayFrequency.weekly,
 }
```

### PrefilledData Sanitization

Prefilled data must align with the type definitions above, and any fields with an accepted-value enum must use a valid enum value. If you prefill user data and any type/value is invalid, that attribute will be stripped and the lead will have to enter it again manually.

## Event Handlers Implementation

{% content-ref url="../event-handlers-for-real-time-tracking" %}
[event-handlers-for-real-time-tracking](https://even-financial.gitbook.io/developer-center/embeddable-integrations/mobile-sdks/event-handlers-for-real-time-tracking)
{% endcontent-ref %}
