Google Ads Scripts 获取账户信息如果获取当前所获取的信息时间

57 views
Skip to first unread message

te3 fu

unread,
Mar 4, 2025, 12:46:25 AM3/4/25
to Google Ads Scripts Forum
function getCurrentAccountDetails() {
 
const currentAccount = AdsApp.currentAccount();
  console
.log(`Customer ID: ${currentAccount.getCustomerId()}`);
  console
.log(`Currency Code: ${currentAccount.getCurrencyCode()}`);
  console
.log(`Timezone: ${currentAccount.getTimeZone()}`);
 
const stats = currentAccount.getStatsFor('YESTERDAY');
  console
.log(`${stats.getClicks()} clicks YESTERDAY`);
  console
.log(`${stats.getImpressions()} impressions YESTERDAY`);
 
return stats;
}

如上述脚本 如果获取YESTERDAY是具体哪一天 就是想获取年-月-日这种形式的日期

Suryansh Misra

unread,
Mar 4, 2025, 1:55:52 AM3/4/25
to te3 fu 提供方 Google Ads Scripts Forum
Hi,

Can you please share the whole updated script?

Regards,

SURYANSH MISRA

Application Engineer - IMS
line

Mobile: +91 7042013147
Phone: +911120-6993088
Email: sury...@xoogle.in
Website: xoogle.in
Facebook icon LinkedIn icon Twitter icon 


--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scrip...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/adwords-scripts/211fb554-3839-448a-a746-aa8368a3b522n%40googlegroups.com.

The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to share any part of this message with any third party, without a written consent of the sender. If you received this message by mistake, please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.

Google Ads Scripts Forum Advisor

unread,
Mar 4, 2025, 4:01:16 AM3/4/25
to adwords...@googlegroups.com
Hi,

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

We would like to inform you that this product officially offers support in English and it would be great if you can reply in English.  If required, we will use Google Translate to support/assist you in the best manner possible.

Based on the provided script, I have observed that the script has executed successfully. If you are looking for data in the format of "yyyy-MM-dd" for the clicks and impressions, you can refer to the below sample code. You can also go through the dates and time documentation for more information.
const stats = currentAccount.getStatsFor('YESTERDAY');

const date = new Date();

date.setDate(date.getDate()-1);
 
const YESTERDAY = Utilities.formatDate(date,currentAccount.getTimeZone(),'yyyy-MM-dd');

console.log(`${stats.getClicks()} clicks ${YESTERDAY}`);
Feel free to get back in case of any further queries.
 

Thanks,
 
Google Logo Google Ads Scripts Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-03-04 09:00:47Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH5sC:ref" (ADR-00291283)



HXJQ Ore Processing Plant

unread,
Mar 6, 2025, 12:38:38 AM3/6/25
to Google Ads Scripts Forum
您好 再问一下 如果获取广告系列的类型,广告系列类型是哪个字段 

Google Ads Scripts Forum Advisor

unread,
Mar 6, 2025, 3:05:31 AM3/6/25
to adwords...@googlegroups.com
Hi,


We would like to inform you that this product officially offers support in English and it would be great if you can reply in English.  If required, we will use Google Translate to support/assist you in the best manner possible.

I would recommend you to use the reporting option available in Google Ads Scripts. You can refer to the below code to get the campaign data. You can add additional fields by using the campaign query builder to retrieve the campaign data.
function main() {

  const searchResults = AdsApp.search(
      'SELECT campaign.name,campaign.advertising_channel_type FROM campaign');

  for (const row of searchResults) {
    const campaignName = row.campaign.name;
    const campaignType = row.campaign.advertisingChannelType;
    console.log(`${campaignName}, ${campaignType}`);
  }
}
Feel free to get back in case of any further queries.
 

Thanks,
 
Google Logo Google Ads Scripts Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-03-06 08:04:44Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH5sC:ref" (ADR-00291283)



Reply all
Reply to author
Forward
0 new messages