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

# Google Ads

> Send conversions to Google Ads with enhanced conversions for better attribution

The Google Ads integration sends conversions to Google Ads using the Conversions API with enhanced conversions, providing server-side tracking and improved match rates for accurate attribution.

## What Gets Synced

**Ad Performance Data (From Google):**

* Campaign, ad group stats
* Spend, impressions, clicks
* Cost per click, conversions
* ROAS metrics

**Conversion Data (To Google):**

* Purchase events with revenue
* Lead gen conversions
* Signup/registration events
* Add to cart events
* Custom conversions you configure

## How It Works

### Conversion Flow

**1. User Clicks Google Ad**

```
User clicks Google ad
Google appends gclid to URL
URL: https://yoursite.com/?gclid=Cj0KCQ...
```

**2. DATALYR Captures Click ID**

```
DATALYR tracking script captures:
- gclid: Cj0KCQ...
- gbraid: (for iOS 14.5+ app installs)
- _gcl_aw cookie (Google Ads)
Stores in visitor profile: anon_abc123
```

**3. User Converts**

```
User completes purchase: $149.99
DATALYR tracks conversion event
```

**4. Conversion Sent to Google Ads API**

```
DATALYR sends offline conversion:
- Conversion Action: Purchase
- Value: $149.99
- gclid: Cj0KCQ... (from Day 1)
- Enhanced data: email, phone (hashed)
- Order ID for deduplication
```

**5. Google Attributes Conversion**

```
Google receives conversion
Matches gclid to original ad click
Attributes $149.99 to Google Ads campaign
Updates Smart Bidding with conversion data
```

**Result:** Purchase correctly attributed to Google ad, optimizing Smart Bidding.

## Setup

### 1. Connect Google Ads Account

1. Navigate to Settings → Sources in DATALYR
2. Click "Connect" next to Google Ads
3. Log in to Google account
4. Select Google Ads account
5. Grant permissions:
   * View ad performance
   * Upload conversions
   * View and manage conversion actions
6. Click "Allow"

### 2. Select Primary Ad Account

After connecting:

1. DATALYR shows all accessible ad accounts
2. Select your primary Google Ads customer ID
3. DATALYR fetches existing conversion actions
4. Click "Save"

### 3. Create Conversion Actions

In Google Ads:

1. Go to Tools → Conversions
2. Click "+" to create conversion action
3. Select "Import" → "Other data sources"
4. Name: "Purchase" (or your event name)
5. Category: Purchase
6. Value: Use different values for each conversion
7. Count: One (recommended)
8. Conversion window: 30 days (default)
9. Save conversion action

Repeat for each conversion type (Lead, Signup, etc.)

### 4. Map Events in DATALYR

1. Go to Settings → Conversion Rules

2. Map your events to Google conversion actions:
   * `purchase` → Purchase conversion action
   * `lead` → Lead conversion action
   * `signup` → Signup conversion action

3. Configure conversion values:
   * Dynamic (use order total)
   * Fixed value per conversion

### 5. Verify Integration

**Test Conversion:**

1. Click Google ad with gclid parameter
2. Complete conversion on your site
3. Wait 3-4 hours (Google processing time)
4. Check Google Ads → Tools → Conversions
5. Verify conversion appears with "Upload" source

## Enhanced Conversions

### What Are Enhanced Conversions

Enhanced conversions improve match rates by sending hashed customer data (email, phone, address) with conversions for better attribution.

**Standard Conversion:**

```javascript theme={null}
{
  "gclid": "Cj0KCQ...",
  "conversion_value": 99.99,
  "conversion_currency": "USD"
}
```

**Enhanced Conversion:**

```javascript theme={null}
{
  "gclid": "Cj0KCQ...",
  "conversion_value": 99.99,
  "conversion_currency": "USD",
  "user_identifiers": [{
    "hashed_email": "sha256_hash",
    "hashed_phone_number": "sha256_hash",
    "address_info": {
      "hashed_first_name": "sha256_hash",
      "hashed_last_name": "sha256_hash",
      "city": "san francisco",
      "state": "ca",
      "postal_code": "94102",
      "country": "us"
    }
  }]
}
```

### Benefits

* **Higher match rates:** 15-30% improvement
* **Better Smart Bidding:** More accurate conversion data
* **Cross-device attribution:** Match users across devices
* **iOS 14+ recovery:** Improve attribution despite tracking limits

## Click IDs

### gclid (Google Click ID)

Standard click ID for web clicks:

```
URL: https://example.com/?gclid=Cj0KCQjw...
```

**Captured by DATALYR automatically**

### gbraid (Google SKAN Identifier)

For iOS 14.5+ app install attribution:

```
URL: https://example.com/?gbraid=1234567890...
```

**Used when:**

* User clicks ad on iOS device
* Privacy-preserving attribution needed

### wbraid (Web-to-App Identifier)

For web-to-app conversions:

```
URL: https://example.com/?wbraid=abcd1234...
```

**Used when:**

* User clicks web ad
* Converts in mobile app

DATALYR automatically detects and uses the correct identifier.

## Attribution

### Cross-Device Attribution

DATALYR links conversions across devices using email matching:

**Example:**

**Mobile (Day 1):**

```
User clicks Google ad on mobile
gclid captured: Cj0KCQ...
Visitor ID: anon_mobile_123
```

**Desktop (Day 5):**

```
User purchases on desktop
Email: user@example.com
Order: $149.99

DATALYR links:
1. Desktop visitor → user@example.com
2. Mobile visitor → user@example.com
3. Finds gclid from mobile click
4. Sends conversion with original gclid
```

**Result:** Desktop purchase attributed to mobile Google ad.

### Attribution Windows

**Google Default Windows:**

* 30-day click attribution (configurable)
* 1-day view attribution (optional)

**DATALYR Settings:**

* 30-day default attribution window
* Customizable per workspace
* Matches Google's conversion window setting

## Conversion Tracking

### Offline Conversions

DATALYR sends offline conversions to Google Ads:

**Upload Method:**

```
Google Ads API v21
Endpoint: OfflineConversionUploadService
Method: uploadClickConversions
```

**Data Sent:**

```javascript theme={null}
{
  "conversions": [{
    "gclid": "Cj0KCQ...",
    "conversion_action": "customers/123/conversionActions/456",
    "conversion_date_time": "2025-09-29 10:30:45-07:00",
    "conversion_value": 149.99,
    "currency_code": "USD",
    "order_id": "ORDER_789", // Deduplication
    "user_identifiers": [{
      "hashed_email": "...",
      "hashed_phone_number": "...",
      "address_info": {...}
    }]
  }]
}
```

### Deduplication

**Order ID Method:**
DATALYR uses order IDs to prevent duplicate conversions:

```javascript theme={null}
// Same order won't be counted twice
Conversion 1: order_id = "ORDER_123"
Conversion 2: order_id = "ORDER_123" (duplicate, ignored by Google)
```

**Best Practice:**

* Always include order\_id for purchases
* Use unique IDs for each conversion
* Google deduplicates within 24 hours

## Event Mapping

### Standard Conversions

| Your Event       | Google Conversion Action | Value            |
| ---------------- | ------------------------ | ---------------- |
| `purchase`       | Purchase                 | Order total      |
| `lead`           | Submit lead form         | Fixed or dynamic |
| `signup`         | Sign up                  | LTV or fixed     |
| `add_to_cart`    | Add to cart              | Cart value       |
| `begin_checkout` | Begin checkout           | Cart total       |

### Custom Conversions

Create custom conversion actions for specific events:

```javascript theme={null}
// Track free trial starts
datalyr.track('trial_started', {
  plan: 'pro',
  value: 99 // Monthly plan value
});

// Maps to Google conversion action: "Trial Started"
```

## Advanced Features

### Cart Data

Send product details for Performance Max campaigns:

```javascript theme={null}
{
  "cart_data": {
    "items": [{
      "product_id": "SKU123",
      "quantity": 2,
      "unit_price": 49.99
    }]
  }
}
```

**Benefits:**

* Better product-level insights
* Improved Performance Max optimization
* Product feed matching

### User-Provided Data

Enhanced conversions with comprehensive data:

```javascript theme={null}
{
  "user_identifiers": [{
    "hashed_email": "sha256_hash",
    "hashed_phone_number": "sha256_hash",
    "address_info": {
      "hashed_first_name": "sha256_hash",
      "hashed_last_name": "sha256_hash",
      "city": "san francisco",
      "state": "ca",
      "postal_code": "94102",
      "country": "us"
    }
  }],
  "user_identifier_source": "FIRST_PARTY"
}
```

All data is SHA-256 hashed before sending.

## Troubleshooting

### Conversions Not Appearing

**Check:**

1. Integration is connected and active
2. Conversion action exists in Google Ads
3. Event has gclid parameter
4. Within attribution window (30 days)
5. Wait 3-4 hours for Google processing

**Common Issues:**

* Missing gclid: User didn't click Google ad
* Wrong customer ID: Verify ad account selected
* Conversion action not set up: Create in Google Ads first

### Low Conversion Volume

**Increase conversions by:**

1. Send all conversion events (not just purchases)
2. Include enhanced data (email, phone)
3. Map more events to conversion actions
4. Verify gclid is captured on all entry pages

### Match Rate Issues

**Improve match rates:**

1. Send email with every conversion
2. Include phone number (E.164 format)
3. Send full address data (city, state, zip)
4. Use consistent data formatting

**Target:** 70%+ match rate for enhanced conversions

## Smart Bidding

### How Conversions Improve Bidding

Google Smart Bidding uses conversion data to optimize:

* **Target ROAS:** Maximize revenue at target return
* **Target CPA:** Get conversions at target cost
* **Maximize Conversions:** Get most conversions in budget
* **Maximize Conversion Value:** Maximize revenue

**More conversion data = Better optimization**

### Best Practices

1. **Send all conversions:** Including micro-conversions
2. **Accurate values:** Use actual order values
3. **Timely uploads:** DATALYR sends immediately
4. **30+ conversions/month:** Minimum for Smart Bidding

## Data Privacy

**Customer Data:**

* All emails, phones, names are SHA-256 hashed
* No plaintext PII sent to Google
* GDPR compliant
* E.164 phone formatting for accuracy

**Hashing Example:**

```javascript theme={null}
// Before
Email: "user@example.com"
Phone: "+14155551234"

// After (sent to Google)
hashed_email: "b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"
hashed_phone_number: "8c2b7e9e4e7e3f7a5d0c5f6e4e7e3f7a5d0c5f6e4e7e3f7a5d0c5f6e4e7e3f7a"
```

## Next Steps

<CardGroup cols={3}>
  <Card title="Meta Ads" icon="meta" href="/integrations/meta-ads">
    Send conversions to Facebook
  </Card>

  <Card title="TikTok Ads" icon="tiktok" href="/integrations/tiktok-ads">
    Track TikTok ad performance
  </Card>

  <Card title="OpenAI Ads" icon="https://mintcdn.com/datalyr/lfO2N_Gfr0p_cPiJ/logos/openai-logo.png?fit=max&auto=format&n=lfO2N_Gfr0p_cPiJ&q=85&s=8f10f5c1fb139ba14740a9791d32fa5e" href="/integrations/openai-ads" width="1000" height="1000" data-path="logos/openai-logo.png">
    Send conversions to OpenAI's CAPI
  </Card>

  <Card title="Conversion Rules" icon="arrows-turn-to-dots" href="/integrations/conversion-rules">
    Configure conversion mapping
  </Card>

  <Card title="Customer Journeys" icon="route" href="/features/customer-journeys">
    View attribution paths
  </Card>
</CardGroup>

## Need Help?

Questions about Google Ads integration? Check our [troubleshooting guide](/troubleshooting/integration-errors) or contact support.
