Hello, Is it possible to have google automatically add YouTube placement exclusions based on certain criteria in the channel names?
I am trying to make a script that excludes channels with characters in their title that do not match latin or germanic. I am also trying to have it filter our children's keywords. It keeps breaking with an error like this: Ga: 'ad_group_id' is not a valid field in AD_PERFORMANCE_REPORT. Please check your spelling and casing. at main (Code:22:27) I have tried various placement group fields from google's API doc. *Here is my code currently:* function main() { const keywords = ['minecraft', 'skibidi', 'cocomelon', 'peppa pig', 'roblox']; const channels = []; const dateRangeStart = getDateNDaysAgo(30); const dateRangeEnd = getFormattedDate(new Date()); // Query for YouTube channel placements over the last 30 days const query = ` SELECT ad_group_id, ad_group_name, creative_id, creative_name, placement_url FROM AD_PERFORMANCE_REPORT WHERE placement_type = 'YOUTUBE_CHANNEL' AND segments.date >= '${dateRangeStart}' AND segments.date <= '${dateRangeEnd}'`; const report = AdsApp.report(query); const rows = report.rows(); while (rows.hasNext()) { const row = rows.next(); const channelName = row.creative_name; const placementUrl = row.placement_url; // Check if the channel name contains non-Latin or non-Germanic characters if (containsNonLatinCharacters(channelName) || containsKeywords(channelName, keywords)) { channels.push({ name: channelName, url: placementUrl }); } } // Output the results if (channels.length > 0) { Logger.log('YouTube Channels Meeting Criteria:'); channels.forEach(channel => { Logger.log(`Name: ${channel.name}, URL: ${channel.url}`); }); } else { Logger.log('No YouTube channels found matching the criteria.'); } } // Function to get the date N days ago in YYYY-MM-DD format function getDateNDaysAgo(n) { const date = new Date(); date.setDate(date.getDate() - n); return getFormattedDate(date); } // Function to format a date in YYYY-MM-DD format function getFormattedDate(date) { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based const day = String(date.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; } // Function to check if a string contains non-Latin or non-Germanic characters function containsNonLatinCharacters(str) { // Regular expression for non-Latin characters const nonLatinRegex = /[^\u0000-\u007F]+/; return nonLatinRegex.test(str); } // Function to check if the channel name contains any specified keywords function containsKeywords(str, keywords) { return keywords.some(keyword => str.toLowerCase().includes(keyword.toLowerCase())); } -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/cfb65eb8-eec7-444c-9a22-dac3c42100e7n%40googlegroups.com.