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

# Column Naming

> How Detrics normalizes column names to snake_case across all platforms

<Info>**Last updated:** March 18, 2026</Info>

## The Problem

Every marketing platform uses its own naming convention for fields:

```
Google Ads:    campaign.name, ad_group.name, metrics.clicks
Meta Ads:      campaign_name, adset_name, clicks
GA4:           sessionSourceMedium, totalUsers
Pinterest:     CAMPAIGN_NAME, TOTAL_IMPRESSION
Shopify:       orderCount, grossSales
```

Writing SQL across platforms means constantly remembering which convention each platform uses, and dealing with dots, camelCase, and inconsistent capitalization.

## The Solution

Detrics normalizes all column names to **snake\_case** before loading data into BigQuery. This means every platform's fields follow the same convention, and you can write clean cross-platform SQL without worrying about naming differences.

## Normalization Rules

Detrics applies these rules in order:

| Rule                                  | Before            | After             |
| ------------------------------------- | ----------------- | ----------------- |
| Dots become underscores               | `campaign.name`   | `campaign_name`   |
| camelCase splits                      | `campaignName`    | `campaign_name`   |
| ALL\_CAPS lowercased                  | `CAMPAIGN_NAME`   | `campaign_name`   |
| Acronyms lowered                      | `CTR`             | `ctr`             |
| Letter-digit boundaries               | `videoViewsP25`   | `video_views_p25` |
| Consecutive underscores collapsed     | `campaign__name`  | `campaign_name`   |
| Leading/trailing underscores stripped | `_campaign_name_` | `campaign_name`   |
| Digit-leading names prefixed          | `7day_click`      | `_7day_click`     |

## Examples

### Before and After

| Platform   | Original Field                         | BigQuery Column                        |
| ---------- | -------------------------------------- | -------------------------------------- |
| Google Ads | `campaign.name`                        | `campaign_name`                        |
| Google Ads | `metrics.cost_micros`                  | `metrics_cost_micros`                  |
| Meta Ads   | `campaign_name`                        | `campaign_name`                        |
| GA4        | `sessionSourceMedium`                  | `session_source_medium`                |
| GA4        | `totalUsers`                           | `total_users`                          |
| Pinterest  | `CAMPAIGN_NAME`                        | `campaign_name`                        |
| Pinterest  | `TOTAL_IMPRESSION`                     | `total_impression`                     |
| Shopify    | `grossSales`                           | `gross_sales`                          |
| Shopify    | `orderCount`                           | `order_count`                          |
| TikTok     | `campaign_name`                        | `campaign_name`                        |
| Meta Ads   | `offsite_conversion.fb_pixel_purchase` | `offsite_conversion_fb_pixel_purchase` |

### Cross-Platform SQL

With normalized column names, cross-platform queries become straightforward:

```sql theme={null}
-- Compare spend across Meta Ads and Google Ads
SELECT
  'Meta Ads' as platform,
  campaign_name,
  SUM(spend) as total_spend
FROM `project.dataset.meta_ads_campaigns`
WHERE date >= '2026-03-01'
GROUP BY campaign_name

UNION ALL

SELECT
  'Google Ads' as platform,
  campaign_name,
  SUM(spend) as total_spend
FROM `project.dataset.google_ads_campaigns`
WHERE date >= '2026-03-01'
GROUP BY campaign_name

ORDER BY total_spend DESC
```

## System Columns

System columns added by Detrics always use the `_detrics_` prefix and are already in snake\_case:

* `_detrics_account_id`
* `_detrics_row_id`
* `_detrics_sync_id`
* `_detrics_synced_at`

These are never affected by normalization rules and are consistent across all tables.

## Type Mapping

In addition to name normalization, Detrics maps platform data types to BigQuery-native types:

| Detrics Type   | BigQuery Type |
| -------------- | ------------- |
| string         | STRING        |
| float, float64 | FLOAT64       |
| integer, int64 | INT64         |
| date           | DATE          |
| datetime       | DATETIME      |
| timestamp      | TIMESTAMP     |
| boolean        | BOOL          |
| percent        | FLOAT64       |
| currency       | FLOAT64       |
| number         | FLOAT64       |
