Fetch GCLID from Google Ads API

On This Page

    The Google Ads API helps export GCLIDs that are not accessible in the Google Ads interface. Using the Google Ads API reports, you can easily obtain the GCLIDs of those who clicked on your ads and use them to improve the efficiency of your campaigns and ads.

    What is Google Ads API

    The Google Ads API allows developers to interact with Google Ads. Thus, you can increase productivity by easily managing your large and complex accounts and campaigns. The Google Ads API allows you to programmatically perform actions that you would perform in the Google Ads user interface. If you have needs beyond the Google Ads interface, you can use the Google Ads API to meet those needs.This article explains how to export your GCLID using the Google Ads API Reports. If you would like to learn more about the Google Ads API, check our upcoming posts and official documentation

    Google Ads API reports are resources that can be queried using the Google Ads API. Different reports are available to meet different needs. These reports can be filtered and sorted using a query language called GAQL. A complete list of report resources can be found on the official Google Ads API website.  https://developers.google.com/google-ads/api/fields/v12/overview

    Click Performance Report (deprecated)

    This report contains statistics collected at each valid and invalid click level. It is served by the Google Adwords API. However, the Google Adwords API was deprecated on April 27, 2022 and is no longer supported. All requests to the AdWords API after that date resulted in an error. If you or your development team encounter these errors, you should switch to the Google Ads API. Instead of ”CLICK PERFORMANCE REPORT”, you prefer “click_view” report.

    Click View Report

    The report you should use to access GCLIDs is the “click_view” report. Click view report presents valid and invalid clicks up to 90 days ago, with metrics collected at each click level. A filter is required to limit the results to one day when using these reports.

    In addition to clicks, you can use this report to access the resources contained in the customer report. You can also segment the metrics of the domains you access from these sources by ad groups and campaigns.

    The fields in each report are divided into 3 sections as “resource fields”, “segments” and “metrics”.

    Click View Report Resource Fields

    There are a total of 19 resource fields in this report. Some of the most used ones are:

    gclid

    GCLID of the click

    name_group_name

    The ad group the click is associated with.

    keyword

    If it exists and is in the SEARCH channel, the keyword the click is associated with.

    keyword_info.match_type

    The match type of the keyword to which the click is associated.

    keyword_info.text

    The text of the keyword (up to 80 characters and 10 words long)

    Click View Report Segments

    There are 6 different segments: name_network_type, click_type, date, device, month_of_year and slot. Some of the most used are:

    name_network_type

    The network type of the ad that the click is associated with

    click_type

    How and where the click occurred. For example: sitelink, google store locator, breadcrumbs.

    date

    In yyyy-MM-dd format, the time of the click. For example: 2018-04-17

    Click View Report Metrics

    There is 1 metric that can be accessed in the Click_view report.

    clicks

    Indicates the number of clicks.

    How to Access Click View Report to Fetch GCLIDs 

    To access a Google Ads API report, you first need to create a GAQL (Google Ads Query Language) query to call the report. Google Ads Query Language allows you to view resources and their related attributes, segments, metrics using Google Ads API.

    For example, using the “click_view” report to get the GCLIDs, your query would be like this:

    With this GAQL query, you can see the clicks on the specific day along with the GCLID, date, customer id, ad group id and campaign id fields.Don’t forget: To run the query created using the click_view report, you need a filter to limit the results to one day. Once your query is ready, simply execute it in the programming language you use with the Google Ads API. In this article, we will explain how to do this with Google Ads Script.

    To create GAQL queries in an interactive way, you can use Google’ Query Builder tool for free: https://developers.google.com/google-ads/api/fields/v11/click_view_query_builder

    Using Google Ads Script to Save Click View Report to Google Sheet

    One way to see GCLIDs using the click_view report with the Google Ads API is to use the Google Ads Script to do this.

    1. Sign in to your Google Ads account.
    2. Select “Tools” from the top right menu, then “Scripts”.
    3. Create a new script by pressing the “+” button.
    4. Click on “New script”.
    5. Run the script using the code below.

    When the script is completed, you will see the newly created spreadsheet file on your Google docs page. In this file, you can see the GCLIDs of the date you specified in your query, along with the dates, customer ids, ad group ids and campaign ids. You can always use the click_view report for different purposes by customizing the script according to your needs. 

    More Similar Posts

    Menu