Campaign name to Ad Performance Report

390 views
Skip to first unread message

Ken Schulz

unread,
Sep 7, 2022, 11:21:07 AM9/7/22
to Google Ads Scripts Forum
Hello community,

I am new to scripts so this might be just an easy task...not for me though... I am trying to add the campaign name to the 'Ad Performance Report' (https://developers.google.com/google-ads/scripts/docs/solutions/ad-performance).

Basically I have 500+ headlines and I need to filter them by campaign name. Either directly in the script, or if the campaign name gets outputted into the spreadsheet I can filter them there. So my question is how do I go about this.

Thank you in advance,
Ken

Google Ads Scripts Forum Advisor

unread,
Sep 8, 2022, 1:25:39 AM9/8/22
to adwords...@googlegroups.com

Hello Ken,

I’m James from the Google Ads scripts support team. Thank you for reaching out to us.

Within the `Ad Performance Report` solution script, you may check the GAQL query below: 

const results = AdsApp.search(`SELECT ${fields} FROM ad_group_ad ` +
        `WHERE metrics.impressions > 0 AND ` +
        `segments.date DURING LAST_7_DAYS`

From that query, you can now filter those headlines by campaign name. You just need to utilize the campaign.name field in the WHERE clause of the mentioned query.  See sample implementation below:

const results = AdsApp.search(`SELECT ${fields} FROM ad_group_ad ` +
        `WHERE metrics.impressions > 0 AND ` +
         `campaign.name = “sample” AND` +
        `segments.date DURING LAST_7_DAYS`

You may try it on your end, then let me know how it goes.

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2dwKZy:ref

Ken Schulz

unread,
Sep 9, 2022, 7:52:25 AM9/9/22
to Google Ads Scripts Forum
Hello James, 
it works! Thank you very much.
Could you also advise how to select campaigns containing a  phrase for example "DE"?

I tried changing the line to 
 `campaign.name CONTAINS "DE" AND` +

but this does not work.

Regards,
Ken

Dne čtvrtek 8. září 2022 v 7:25:39 UTC+2 uživatel adsscripts napsal:

Google Ads Scripts Forum

unread,
Sep 23, 2022, 12:58:21 AM9/23/22
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/2n7CVWCtjbI) from the forum as it wasn't routed to our support queue.

Regards,
Yasmin
Google Ads Scripts Team

Google Ads Scripts Forum

unread,
Oct 6, 2022, 3:39:34 AM10/6/22
to Google Ads Scripts Forum

Hello Ken,

As the new script experience is now based on Google Ads API infrastructure which mainly supports GAQL, the CONTAINS operator is not supported in GAQL. You may refer to this documentation regarding the supported operators in GAQL. You can, however, emulate this behavior using the new REGEXP_MATCH operator instead of CONTAINS. You may refer below:

`campaign.name REGEXP_MATCH ".*DE.*" AND` +

Should you encounter any issues, kindly share with us privately (via the Reply to author option) the following details below:

  • Google Ads CID
  • Script Name
  • Shareable link (guide on Share a file publicly) of the spreadsheet involved in your Script.

If the said option is not available on your end, you may send those through the email alias `googleadsscr...@google.com` instead.

Best Regards,
Maia
Google Ads Scripts Team
Reply all
Reply to author
Forward
0 new messages