How to pass conversion data to Google Ads without firing pixel on the site?

Thanks to conversion information, Google Ads will run the ads more effectively, and you will be able to use smart bidding, set target CPA/ROAS and other automatic campaign optimization.

The easiest way to pass information about conversion to Google Ads is to set up conversion tracking tag. But here comes the problems with it:

  • In order to fire Google Ads tag, you are required to collect a consent from the visitor (at least in countries that adopted GDPR or similar privacy law)
  • Website visitors will see that they are tracked by Google which may not be desired on certain sites due to your brand image, security etc.

So is there a way you can pass conversion information tracked by Piwik PRO to Google Ads without firing any Google’s tags on the website?

Yes, this is possible!

We will use the Offline conversion import option that allows you to import conversions from ad clicks into Google Ads. What you will need is to get a list of Google Click IDs (GCLIDs) associated with the conversion.

The way that this works is when a visitor clicks an ad, Google adds a unique parameter (GCLID) in the URL to the destination. Piwik PRO captures this parameter and stores it in visitor session. You can fetch via API a list of all GCLIDs for the sessions with conversion.

Before we begin, make sure that:

1. Install Insomnia, cURL or other REST API client.

2. Log in to Piwik PRO and create your API credentials (Menu → User panel → API credentials → Generate new credentials)

3. Fetch your access token (see developer’s documentation):

with cURL:

curl -X POST 'https://<your_instance>/auth/token' -H "Content-Type: application/json" --data '{
    "grant_type": "client_credentials",
    "client_id": "your_API_client_id",
    "client_secret": "your_API_client_secret"
}'

with Insomnia:

After you change <your_instance> and <your_API_client_id>, <your_API_client_secret>, click “Refresh token” or make cURL call to check if it’s working correctly.

4. Make the API call

with cURL:

curl --request POST \
  --url https://<your_instance>/api/analytics/v1/sessions/ \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "date_from": "2021-01-01",
    "date_to": "2021-03-31",
    "website_id": "<your_website_id>",
    "offset": 0,
    "limit": 10000,
    "columns": [
        {
            "column_id": "campaign_gclid"
        }
    ],
 "filters": {
    "operator": "and",
    "conditions": [
      {
        "condition": {
          "operator": "neq",
          "value": ""
        },
        "column_id": "campaign_gclid"
      },
            {
        "condition": {
          "operator": "neq",
          "value": 0
        },
        "column_id": "session_total_goal_conversions"
      }
    ]
    },
    "format": "csv"
}'

with Insomnia:

  • Choose “POST” request type to the following endpoint: https://<your_instance>/api/analytics/v1/sessions/
  • Use JSON as a type and paste the following JSON query customizing the <website_id> and dates.
{
    "date_from": "2021-01-01",
    "date_to": "2021-03-28",
    "website_id": "<website_id>",
    "offset": 0,
    "limit": 100000,
    "columns": [
        {
            "column_id": "campaign_gclid"
        }
    ],
 "filters": {
    "operator": "and",
    "conditions": [
      {
        "condition": {
          "operator": "neq",
          "value": ""
        },
        "column_id": "campaign_gclid"
      },
            {
        "condition": {
          "operator": "neq",
          "value": 0
        },
        "column_id": "session_total_goal_conversions"
      }
    ]
    },
    "format": "csv"
}

  • the result of executing the query will be a CSV with timestamps and GCLIDs for all sessions that has at least one conversion
  • you can click “Preview” → Save Raw Response to save it to a file

5. Once you have the CSV, open it in Excel or Google Sheets and customize it to the format that is required by Google Ads and follow their import instructions.

PS. We plan to add GCLID as a dimension in Custom Reports editor, so that you can do it directly from Piwik PRO’s user interface.

There is an easier option now described in this article:

A post was split to a new topic: Offline conversions import