> For the complete documentation index, see [llms.txt](https://docs.aloop.icustomer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aloop.icustomer.ai/setup-and-onboarding/preparing-your-data.md).

# Preparing your data

Get your data ready before connecting: formatting rules, entity relationships, PII handling, and the readiness checklist.

Well-prepared data is the difference between a system that decides well and one that guesses. Clean identifiers raise match rates, complete fields keep good accounts in the ranking, and correct links between people and companies make every score sharper.

This page is about readiness. What tables you need is covered in [Required tables](/integrations/required-tables.md); connecting a specific tool is covered in [Your stack](/integrations/stack.md).

## Formatting rules

The matching keys have to be clean, because signals only attach to clean identifiers.

| Field     | Good                                 | Bad                     |
| --------- | ------------------------------------ | ----------------------- |
| Email     | `jane@acme.com` (lowercase, trimmed) | `Jane@Acme.com`         |
| Domain    | `acme.com`                           | `https://www.acme.com/` |
| Phone     | `+14155551234` (E.164)               | `(415) 555-1234`        |
| Timestamp | ISO 8601 or Unix                     | `01/15/2024 10:30 AM`   |

Typical normalization, run in your warehouse before connecting:

```sql
UPDATE contacts SET email = LOWER(TRIM(email)) WHERE email IS NOT NULL;

UPDATE accounts SET domain = LOWER(
  REGEXP_REPLACE(REGEXP_REPLACE(domain, '^https?://(www\.)?', ''), '/.*$', '')
);
```

## Uniqueness and duplicates

Primary keys must be unique: duplicate IDs cause scoring errors downstream.

```sql
SELECT account_id, COUNT(*) FROM accounts
GROUP BY account_id HAVING COUNT(*) > 1;
-- should return 0 rows
```

{% hint style="warning" %}
Dedupe examples that rely on `ctid` are Postgres-only. On Snowflake, BigQuery, Databricks, or Redshift, dedupe with a window function (`ROW_NUMBER() OVER (PARTITION BY account_id ORDER BY updated_at DESC)`) instead.
{% endhint %}

## Link people to companies

Every contact should carry an `account_id`. Orphan contacts still score, but they cannot contribute to account-level decisions.

```sql
-- find orphans
SELECT COUNT(*) FROM contacts c
LEFT JOIN accounts a ON c.account_id = a.account_id
WHERE a.account_id IS NULL;

-- link by email domain (excluding free-mail)
UPDATE contacts c SET account_id = a.account_id
FROM accounts a
WHERE SPLIT_PART(c.email, '@', 2) = a.domain AND c.account_id IS NULL;
```

## Handling PII

You choose how each sensitive field is handled at ingestion:

* **Hash**: one-way SHA-256, still usable for matching. The default for email, IP, and device IDs.
* **Mask**: partial visibility for operators (`***-***-1234`).
* **Encrypt**: reversible, for fields authorized users need to read back.
* **Exclude**: not ingested at all.

Hashing is consistent within your workspace, so identity resolution and ad-platform matching work without exposing the raw value. Full details live in [Security model](/security-and-compliance/security-model.md).

## Readiness checklist

* [ ] Required fields populated ([Required tables](/integrations/required-tables.md))
* [ ] Primary keys unique
* [ ] Emails lowercase and trimmed; domains cleaned
* [ ] Timestamps in a standard format
* [ ] Contacts linked to accounts
* [ ] `updated_at` columns present for incremental sync
* [ ] PII handling chosen per field

When the list is green, connect your sources (start with your CRM; see [CRM sync](https://github.com/colby-iCustomer/audience-loop-user-guide-public/tree/main/integrations/crm-sync.md)), then watch [Data health](/setup-and-onboarding/data-health.md) after you connect.

## Outside the app

Readiness checks can be run outside the app via [API](/settings/api-keys.md) and [MCP](/iharness/bring-your-own-agent.md) as well.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.aloop.icustomer.ai/setup-and-onboarding/preparing-your-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
