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

# Upsert conversion

> Create or update a Google Ads conversion action

Create or update a Google Ads conversion action

```http theme={null}
PUT https://services.leadconnectorhq.com/ad-publishing/google/conversions
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Body

<ParamField body="locationId" type="string" required default="loc_abc123">
  Account identifier
</ParamField>

<ParamField body="conversionId" type="string" default="conv_456">
  Conversion identifier
</ParamField>

<ParamField body="name" type="string" required default="Purchase Conversion">
  Conversion name
</ParamField>

<ParamField body="type" type="string" required default="WEBPAGE">
  Conversion type Posibles valores: 'UPLOAD\_CLICKS', 'UPLOAD\_CALLS', 'WEBPAGE', 'LEAD\_FORM\_SUBMIT'
</ParamField>

<ParamField body="category" type="string" required default="PURCHASE">
  Conversion category
</ParamField>

<ParamField body="valueSettings" type="object" required>
  Value settings that control how monetary value is attributed to conversions
</ParamField>

<ParamField body="countingType" type="string" required default="ONE_PER_CLICK">
  How conversions are counted per interaction Posibles valores: 'ONE\_PER\_CLICK', 'MANY\_PER\_CLICK'
</ParamField>

<ParamField body="attributionModel" type="string" required default="GOOGLE_ADS_LAST_CLICK">
  Attribution model used to credit conversions Posibles valores: 'GOOGLE\_SEARCH\_ATTRIBUTION\_DATA\_DRIVEN', 'GOOGLE\_ADS\_LAST\_CLICK'
</ParamField>

<ParamField body="clickThroughWindow" type="number" required default="30">
  Click-through conversion window in days
</ParamField>

## Respuestas

<Accordion title="200 - Response" />

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT 'https://services.leadconnectorhq.com/ad-publishing/google/conversions' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "locationId": "loc_abc123",
    "conversionId": "conv_456",
    "name": "Purchase Conversion",
    "type": "WEBPAGE",
    "category": "PURCHASE",
    "valueSettings": {
      "defaultValue": "10.00",
      "defaultCurrencyCode": "USD",
      "alwaysUseDefaultValue": false
    },
    "countingType": "ONE_PER_CLICK",
    "attributionModel": "GOOGLE_ADS_LAST_CLICK",
    "clickThroughWindow": 30
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/google/conversions', {
    method: 'PUT',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"locationId": "loc_abc123", "conversionId": "conv_456", "name": "Purchase Conversion", "type": "WEBPAGE", "category": "PURCHASE", "valueSettings": {"defaultValue": "10.00", "defaultCurrencyCode": "USD", "alwaysUseDefaultValue": false}, "countingType": "ONE_PER_CLICK", "attributionModel": "GOOGLE_ADS_LAST_CLICK", "clickThroughWindow": 30}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'PUT',
      'https://services.leadconnectorhq.com/ad-publishing/google/conversions',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"locationId": "loc_abc123", "conversionId": "conv_456", "name": "Purchase Conversion", "type": "WEBPAGE", "category": "PURCHASE", "valueSettings": {"defaultValue": "10.00", "defaultCurrencyCode": "USD", "alwaysUseDefaultValue": false}, "countingType": "ONE_PER_CLICK", "attributionModel": "GOOGLE_ADS_LAST_CLICK", "clickThroughWindow": 30},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/ad-publishing/google/conversions');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'PUT',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode({'locationId': 'loc_abc123', 'conversionId': 'conv_456', 'name': 'Purchase Conversion', 'type': 'WEBPAGE', 'category': 'PURCHASE', 'valueSettings': {'defaultValue': '10.00', 'defaultCurrencyCode': 'USD', 'alwaysUseDefaultValue': false}, 'countingType': 'ONE_PER_CLICK', 'attributionModel': 'GOOGLE_ADS_LAST_CLICK', 'clickThroughWindow': 30}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
