Тёмный

How To See Where PMAX Is Spending Your Budget | Performance Max Channel Spend Allocation Script 

3B1
Подписаться 244
Просмотров 146
50% 1

Today I want to help open up the PMAX black box and show you how to use a script to pull channel spend and performance data directly from the Google Ads API into a Google Sheet.
Prefer to read? Visit our blog at 3b1.ie/blog/ho...
Spreadsheet to copy: docs.google.co...
Google Ads Script:
function main() {
let ss = SpreadsheetApp.openByUrl('INSERT SHEET HERE'); // enter the URL of YOUR sheet over there -
// no need to touch any code below this line --------------------------
// define commonly used query elements. wrap with spaces for safety
let impr = ' metrics.impressions ';
let clicks = ' metrics.clicks ';
let cost = ' metrics.cost_micros ';
let conv = ' metrics.conversions ';
let value = ' metrics.conversions_value ';
let allConv = ' metrics.all_conversions ';
let allValue = ' metrics.all_conversions_value ';
let views = ' metrics.video_views ';
let cpv = ' metrics.average_cpv ';
let segDate = ' segments.date ';
let prodTitle = ' segments.product_title ';
let campName = ' campaign.name ';
let adgName = ' ad_group.name ';
let chType = ' campaign.advertising_channel_type ';
let adStatus = ' ad_group_ad.status ';
let adPerf = ' ad_group_ad_asset_view.performance_label ';
let adType = ' ad_group_ad_asset_view.field_type ';
let agId = ' asset_group.id ';
let aId = ' asset.id ';
let adPmaxPerf = ' asset_group_asset.performance_label ';
let assetText = ' asset.text_asset.text ';
let assetSource = ' asset.source ' ;
let adUrl = ' asset.image_asset.full_size.url ';
let youtubeTitle = ' asset.youtube_video_asset.youtube_video_title ';
let youtubeId = ' asset.youtube_video_asset.youtube_video_id ';
let assetType = ' asset_group_asset.field_type ';
let agStrength = ' asset_group.ad_strength ';
let agStatus = ' asset_group.status ';
let aIdCamp = ' segments.asset_interaction_target.asset ';
let interAsset = ' segments.asset_interaction_target.interaction_on_this_asset '
let aIdAsset = ' asset.resource_name ';
let asgName = ' asset_group.name ';
let lgType = ' asset_group_listing_group_filter.type ';
let pMaxOnly = ' AND campaign.advertising_channel_type = "PERFORMANCE_MAX" ';
let searchOnly = ' AND campaign.advertising_channel_type = "SEARCH" ';
let agFilter = ' AND asset_group_listing_group_filter.type != "SUBDIVISION" ';
let adgEnabled = ' AND ad_group.status = "ENABLED" AND campaign.status = "ENABLED" AND ad_group_ad.status = "ENABLED" ';
let asgEnabled = ' asset_group.status = "ENABLED" AND campaign.status = "ENABLED" ';
let notInter = ' AND segments.asset_interaction_target.interaction_on_this_asset != "TRUE" '
let date07 = ' segments.date DURING LAST_7_DAYS '
let date30 = ' segments.date DURING LAST_30_DAYS '
let order = ' ORDER BY campaign.name';

// build queries
let cd = [segDate, campName, cost, conv, value, views, cpv, impr, clicks, chType] // campaign by day
let campQuery = 'SELECT ' + cd.join(',') +
' FROM campaign ' +
' WHERE ' + date30 + pMaxOnly + order ;
let dv = [segDate, campName, aIdCamp, cost, conv, value, views, cpv, impr, chType, interAsset] // inter by day
let dvQuery = 'SELECT ' + dv.join(',') +
' FROM campaign ' +
' WHERE ' + date30 + pMaxOnly + notInter + order ;
let p = [campName, prodTitle, cost, conv, value, impr, chType] // product totals
let pQuery = 'SELECT ' + p.join(',') +
' FROM shopping_performance_view ' +
' WHERE ' + date30 + pMaxOnly + order ;
let ag = [segDate, campName, asgName, agStrength, agStatus, lgType, impr, clicks, cost, conv, value] // asset group by day
let agQuery = 'SELECT ' + ag.join(',') +
' FROM asset_group_product_group_view ' +
' WHERE ' + date30 + agFilter
let ads = [campName, asgName, agId, aIdAsset, assetType, adPmaxPerf, agStrength, agStatus, assetSource] // pMax ads
let adsQuery = 'SELECT ' + ads.join(',') +
' FROM asset_group_asset ' +
' WHERE ' + asgEnabled;
// call report function to pull data & push to named tabs in the sheet
runReport(campQuery, ss.getSheetByName('r_camp'));
runReport(dvQuery, ss.getSheetByName('r_dv'));
runReport(pQuery, ss.getSheetByName('r_prod_t'));
runReport(agQuery, ss.getSheetByName('r_ag'));
runReport(adsQuery, ss.getSheetByName('r_ads'));
}
// query & export report data to named sheet
function runReport(q,sh) {
const report = AdsApp.report(q);
report.exportToSheet(sh);
}
Follow me on LinkedIn for more tips and strategies: www.linkedin.com/in/christian-donovan-b31710112

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 5   
@weblinkagency
@weblinkagency Месяц назад
Thanks for the great script and video. One question - how can I convert the spend to dollars from pounds?
@3b1agency
@3b1agency Месяц назад
Hi, I'm glad you found it useful! The script exports raw numbers, and the Google Sheet is actually set to $'s by default. All you have to do to change the currency is change the $ symbols in the sheet.
@KanishkSingh-xt6ny
@KanishkSingh-xt6ny 28 дней назад
Can we take out data for last 180 days? How can we modify it?
@3b1agency
@3b1agency 28 дней назад
Hi Kanishk, technically you can do that but it isn't very practical. You would have to change the dates manually every time before you rang it. Essentially you would have to swap out one of the date lines that start with "let date07" or "let date30" with code like the below. Adding in dates and in brackets. I wouldn't really advise it, but feel free to try to make the below work for your needs. let today = new Date(); let pastDate = new Date(); pastDate.setDate(today.getDate() - 180); let todayFormatted = Utilities.formatDate(today, AdsApp.currentAccount().getTimeZone(), 'yyyyMMdd'); let pastDateFormatted = Utilities.formatDate(pastDate, AdsApp.currentAccount().getTimeZone(), 'yyyyMMdd'); let date180 = ' segments.date BETWEEN ' + pastDateFormatted + ' AND ' + todayFormatted;
Далее
Добрая весть 😂
00:21
Просмотров 588 тыс.
13 Things To Remove From Your Website Immediately
12:33
Hide your files like a hacker (5 Ways)
19:17
Просмотров 88 тыс.
Why Does Everyone Underestimate Chrome Extensions?
1:17:42
Learn 80% of Perplexity in under 10 minutes!
9:52
Просмотров 42 тыс.