pull data from ads with campaing name, cost e Final URL with sufix

56 views
Skip to first unread message

Razix Desinsetizadora

unread,
Dec 15, 2023, 4:46:00 AM12/15/23
to Google Ads API and AdWords API Forum
Good afternoon,

I tried a lot to extract the data from ADS with the following columns:
cost
CPC
Average CPC
name campaign
Final URL with suffix

This was the code I came closest to, but if you have one that already works, could you provide it to me?

function main() {
  try {
    var SHEET_NAME = "ADS";

   
    var dataInicial = "2023-10-01";
    var dataFinal = "2023-12-31";

    var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
    var sheet = spreadsheet.getSheetByName(SHEET_NAME);

    sheet.clear();

    var CAMPOS = ["Data", "Nome da Campanha", "Cliques", "Impressões", "CTR", "Custo"];

    sheet.appendRow(CAMPOS);

    var report = AdsApp.report(
      "SELECT Date, CampaignName, Clicks, Impressions, Ctr, Cost " +
      "FROM CAMPAIGN_PERFORMANCE_REPORT " +
      "WHERE Date >= '" + dataInicial + "' AND Date <= '" + dataFinal + "'"
    );

    var rows = report.rows();
    while (rows.hasNext()) {
      var row = rows.next();
      var rowData = [
        row['Date'],
        row['CampaignName'],
        row['Clicks'],
        row['Impressions'],
        row['Ctr'],
        row['Cost']
      ];
      sheet.appendRow(rowData);
    }
  } catch (error) {
    console.error("Erro no script:", error.message);
  }
}


Google Ads API Forum Advisor

unread,
Dec 15, 2023, 9:26:02 AM12/15/23
to contat...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

After reviewing your concern, I understand that you are trying to extract the data from Google Ads. Could you please confirm if you are using Google Ads API or Google Ads Scripts? If you are using Google Ads API, kindly provide us with the uncropped UI screenshot including the customer ID to assist you better.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02r1yTy:ref"

Thanks,
 
Google Logo Google Ads API Team


Razix Desinsetizadora

unread,
Dec 15, 2023, 11:46:21 AM12/15/23
to ads...@forumsupport.google, adwor...@googlegroups.com
Good morning,

Yes, I'm using google ADS script.

I would like to automatically extract the campaign name, final URL with suffix, cost, CPC and average cost to my google sheet. I'm going to put a trigger to exit every hour.


image.png

image.png




Para
Jorge Chagas
Resp. Técnico

visite nossas qualificações no google:

Dedetizadora Razix Controle de Vetores

Google Ads API Forum Advisor

unread,
Dec 15, 2023, 5:36:02 PM12/15/23
to contat...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

By reviewing your concern, I understand that you are using Google Ads Scripts.

Please note that our team can only assist with technical queries or concerns related to the Google Ads API. As this issue is related to Google Ads Scripts, I am routing this request to the Google Ads Scripts team, as they are well equipped to assist you with this.

Razix Desinsetizadora

unread,
Dec 18, 2023, 1:15:53 AM12/18/23
to Google Ads Scripts Forum Advisor, adwor...@googlegroups.com

So can you answer another question I have? I'm writing the script in Python, but I need the Developer Token, which according to the documentation only the Google ADS administrator account can provide. I only have one Google ADS account and I can't create an administrator account. Do you know what I can do?

image.png


Att
Jorge Chagas
Resp. Técnico

visite nossas qualificações no google:

Dedetizadora Razix Controle de Vetores
Em sex., 15 de dez. de 2023 às 15:35, Google Ads Scripts Forum Advisor <adssc...@forumsupport.google> escreveu:
Hi,

Thank you for reaching out to the Google Ads Scripts support team.

After reviewing your concern, I understand that you want to extract the data from ADS. I would like to inform you that the script you are using to extract the data is correct. For more information, you can refer to this AdsApp.Report documentation.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02r1yTy:ref"

Thanks,
 
Google Logo Google Ads Scripts Team


Reply all
Reply to author
Forward
0 new messages