Script to export pmax data to Google Spreadsheet

611 views
Skip to first unread message

Orçun Hergüler

unread,
May 2, 2023, 4:54:52 AM5/2/23
to Google Ads Scripts Forum
Hi,

I'm looking for a script that exports the following pmax data to a Google Spreadsheet:

- Network Type Name
- Cost
- Cost Rate by Network Type

Google Ads Scripts Forum

unread,
May 3, 2023, 1:18:49 AM5/3/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/CDn2yfnNsfU) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads Scripts Team

Google Ads Scripts Forum

unread,
May 3, 2023, 1:29:17 AM5/3/23
to Google Ads Scripts Forum
Hi,

Thank you for reaching out to the Google Ads Scripts Team.

I would recommend creating a report [https://developers.google.com/google-ads/scripts/docs/features/reports] in order to achieve this and using the campaign report type [https://developers.google.com/google-ads/api/fields/v13/campaign]. Afterwards, you may specifically filter on the field campaign.advertising_channel_type [https://developers.google.com/google-ads/api/fields/v13/campaign#campaign.advertising_channel_type] to 'PERFORMANCE_MAX'. Kindly refer to the report example [https://developers.google.com/google-ads/scripts/docs/features/reports#report_example] included within the documentation for more information on how to build a report. Furthermore, I would suggest making use of the campaign query builder [https://developers.google.com/google-ads/api/fields/v13/campaign_query_builder] in order to efficiently build your query. In order to export the results to a spreadsheet, I would recommend checking this guide [https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_report#exportToSheet_1] in order to use the exportToSheet() method as well as this guide [https://developers.google.com/google-ads/scripts/docs/examples/spreadsheetapp?hl=en#append-rows-to-a-spreadsheet] for more information on how to append rows to a spreadsheet.

As for the fields `Network Type Name` and `Cost`, kindly check if the fields segments.ad_network_type and metrics.cost_micros are what you're looking for. As for the field `Cost Rate by Network Type`, I would like to request that you provide a complete and uncropped screenshot showing this entity from the Google Ads UI so that we may be able to guide you accordingly. You may send it privately via the Reply to author option. Note that you may need to join the Google Group for you to use this option. If this option is not available on your end still, you may send it through our email (googleadsscr...@google.com) instead.

Best regards,
Google Ads Scripts Team

Orçun Hergüler

unread,
May 3, 2023, 3:37:11 AM5/3/23
to Google Ads Scripts Forum
Hi,


- Cost Rate by Network Type
There is no such field available. I want to create a new column. (Network Type Cost / Total Cost)


function main() {
  var SPREADSHEET_URL = "xx";
  var spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
  var sheet = spreadsheet.getActiveSheet();
  var report = AdsApp.report(
      'SELECT segments.ad_network_type, metrics.cost_micros ' +
      'FROM shopping_performance_view ' +
      'WHERE segments.date DURING LAST_30_DAYS');
  report.exportToSheet(sheet);
}

3 Mayıs 2023 Çarşamba tarihinde saat 08:29:17 UTC+3 itibarıyla Google Ads Scripts Forum şunları yazdı:

Nils Rooijmans

unread,
May 3, 2023, 3:38:14 AM5/3/23
to Google Ads Scripts Forum
unfortunately, a lot of the data in PMax is hidden from us.
Network type only returns "cross network" which won't help you very much.

The best script currently out there that I know of is the PMax insights script by Mike Rhodes.



Hope this helps,

Nils Rooijmans
https://nilsrooijmans.com
See my Google Ads Scripts FAQ to avoid the same mistakes I made: https://nilsrooijmans.com/google-ads-scripts-faq/

Google Ads Scripts Forum

unread,
Jul 11, 2023, 3:58:20 AM7/11/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/CDn2yfnNsfU) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads Scripts Team

Google Ads Scripts Forum

unread,
Jul 11, 2023, 4:25:00 AM7/11/23
to Google Ads Scripts Forum
Hi All,

Please excuse us for only getting back now as your message failed to be routed to our support queue.

@Nils - Thank you for providing your insights on this as well as recommending a script.

If you would like to make use of this field, but is not available for performance max campaigns, I would instead suggest you reach out to the Google Ads API support team and inquire with them if a request could be raised in order to expose this functionality within performance max campaigns. I would like to inform you that Google Ads Scripts' reporting infrastructure is backed by the Google Ads API as per our reporting documentation <https://developers.google.com/google-ads/scripts/docs/features/reports>. If the said information you're aiming to retrieve would be made available via API, then it would likely be also supported by Google Ads Scripts' reporting feature.

You may reach out to them via their public forum: https://groups.google.com/g/adwords-api.

If you'd need further assistance regarding Google Ads Scripts, just let us know.


Best regards,
Google Ads Scripts Team

Reply all
Reply to author
Forward
0 new messages