Re: YouTube Placement Exclusions Script

70 views
Skip to first unread message
Message has been deleted

Nils Rooijmans

unread,
Sep 27, 2024, 2:58:57 AM9/27/24
to Google Ads Scripts Forum
looks like the GAQL query isn't correct, here's an example of something that might work for you: 

SELECT ad_group.id, ad_group.name, detail_placement_view.display_name, detail_placement_view.group_placement_target_url, detail_placement_view.placement, detail_placement_view.placement_type, detail_placement_view.resource_name, detail_placement_view.target_url FROM detail_placement_view WHERE detail_placement_view.placement_type = 'YOUTUBE_CHANNEL'

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/

On Friday 27 September 2024 at 02:28:13 UTC+2 John Boison wrote:
Hello,

I am trying to make a youtube exclusions script that looks at the last 30 days of data on the account level and adds certain youtube channels to an exclusion list based on the following criteria:

1. channel title does not contain latin or germanic characters

2. channel contains certain children's keywords such as "minecraft"

I keep getting 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've tried puling the group view field as well. here is my code:

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()));
}

Google Ads Scripts Forum Advisor

unread,
Sep 27, 2024, 7:17:15 AM9/27/24
to adwords...@googlegroups.com

Hi,

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

@Nils - thank you for providing your insights to the user.

I would like to inform you that the metrics “creative_id and creative_name” are not supported fields in the Google Ads Scripts. Kindly refer to the Google Ads Query Builder to add or remove fields. I would suggest that you use the query provided by Nils and get back to us with the below details if you still face any issues.

  • Google Ads account ID/CID
  • Name of the affected script
You can share the requested details via Reply privately to the author option or a direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vGaxk:ref" (ADR-00269810)

Thanks,
 
Google Logo Google Ads Scripts Team


Message has been deleted
Message has been deleted

Google Ads Scripts Forum Advisor

unread,
Sep 27, 2024, 2:54:36 PM9/27/24
to adwords...@googlegroups.com
Hi,

Kindly note that I have executed a script that you have provided in my test account, and we have not received any error while running the script. So, I would suggest you try running the script again and let us know how it goes at your end. If the issue still persists, please share the following details for further investigation:​ ​ ​ ​ ​ ​ ​
  • Google Ads account ID/CID
  • Name of the affected script.

GERSON ALVES COSTA

unread,
Sep 28, 2024, 11:16:15 AM9/28/24
to Google Ads Scripts Forum
Google ads como escreve uma scripts para WhatsApp atrair cliente para páginas  de pagamento o check-out de afiliados , têm tantas falsidade na Internet pessoas aplicados a gente sobre tags e scripts , GÉRSON 

Google Ads Scripts Forum Advisor

unread,
Sep 30, 2024, 5:53:08 AM9/30/24
to adwords...@googlegroups.com
Hi,

I would like to inform you that this product officially offers support only in English. It would be best to reply in English if you can. If not, we will try to use Google Translate to support you as best as we can.

Please be informed that there is no script available for WhatsApp to attract customers to payment pages or affiliate checkouts using Google Ads scripts. I would suggest you refer to the document Google Ads Scripts to know about all the available scripts.

I hope this helps! Feel free to get back to us if you have any further queries.

Lior Churi

unread,
Sep 30, 2024, 8:26:54 PM9/30/24
to Google Ads Scripts Forum on behalf of adsscripts
hi, you sent me the wrong mail.


Regards,

--
-- 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 on the web visit https://groups.google.com/d/msgid/adwords-scripts/Beno3000000000000000000000000000000000000000000000SKME3X00-0aCO_eaTOSvYwFVu3mviQ%40sfdc.net.


--
Lior Churi
Marketing Analyst
Mobile: +972-52-401-2255

______________________

Reply all
Reply to author
Forward
0 new messages