Posts tagged with javascript

We are using Google ads API and we are getting the refresh_token and access_token from the oauthLibrary.

Now due to some reason (Majorly cause we are using JavaScript and there's no library for JavaScript officially from Google) we are relying on the REST API.

I want to fetch a list of Accounts attached to the the given access token. (no matter manager or not Manager) I just need the list.

I have tried the following endpoint

https://googleads.googleapis.com/v1/customers:listAccessibleCustomers

But I am getting 404 Not found in that, So I think it is discontinued, Any idea how I can fetch the list through REST_API.

I can't seem to figure out why my code isn't returning ads with a specific labels and need help understanding where I went wrong with my code. I am iterating through the ad groups that have a specific label "AUTOENABLE" and then iterating through each ad with the same label but also checking on another script the URL endpoint.

  adCount: 0,   adsEnabled: 0,   adsDisabled: 0,   adsSetEnabled: [],   adsSetDisabled: [] }; function adsTest() {         var ag_iter = AdWordsApp.labels().withCondition("Name = AUTOENABLE").get();      if(ag_iter.totalNumEntities() < 1){     Logger.log("ERROR: No AUTOENABLE label found in AdGroup");     return;            // Iterating through all Ad groups to work individually     while (ag_iter.hasNext()) {     // Getting the ad group and printing it's name     var ag = ag_iter.next();     Logger.log(ag.getName())                   // Taking an iterator from all Ads inside Ad Group     var ad_iter = ag.ads().withCondition("LabelNames = AUTOENABLE").get();     if(ad_iter.totalNumEntities() < 1){     Logger.log("ERROR: No AUTOENABLE label found in Ads.");     return;   }     while(ad_iter.hasNext()){       var ad_iter = ads.next();       checkAd(ad);     }    }   }       report(); } function report(){     Logger.log(stats.adCount + " ads checked");     Logger.log(stats.adsEnabled + " ads are enabled");     Logger.log(stats.adsDisabled + " ads are disabled");     Logger.log((stats.adsSetDisabled.length + stats.adsSetEnabled.length) + " ads modified");     if(stats.adsSetEnabled.length > 0){       Logger.log("Changed to enabled:");       stats.adsSetEnabled.forEach(adLog);     }     if(stats.adsSetDisabled.length > 0){       Logger.log("\nChanged to disabled:");       stats.adsSetDisabled.forEach(adLog);     } } 

I was trying to create a AWS stack to deploy Whatsapp Business client API. But Creating stack throws following error. error: The following resource(s) failed to create: [KMSKey, MountTarget2, MountTarget, lambdaStack, dbStack]

I followed this documentation steps. https://developers.facebook.com/docs/whatsapp/on-premises/get-started/installation/aws

I am working with Google Ads Scripts. Based on my use case, I need to get the impressions, clicks, and other statistics about the products I have in my Google Ads account.

These product statistics will be analyzed in the script and based on certain criteria a Google Sheet document will be updated. The script goes like, retrieving all products (along with their statistics) from Google Ads account, see if the products impression and clicks meet a category (30 Impression, 1 click = Category "A", 20 Impressions, 0 Clicks = "Category B"), determines the product category, open Google Sheet hosted on Google Drive and updates the Category column in the Sheet based on product name or id.

Currently, I am facing an issue with retrieving Products and their statistics from Google Ads Account using Ads Script. I used the following code snippets to look for products but found no method or class that would help me achieve my desired results. I can only retrieve the productGroups, AdGroups, and Campaigns but none of them allow me to extract individual products.

function productGroup(){   var prodGroupIter = AdsApp.productGroups().get();   while (prodGroupIter.hasNext()){     Logger.log("prodGroup: ")     var prodGroup = prodGroupIter.next();     Logger.log(prodGroup.getValue());   } } function adGroup() {   var adGroupIterator = AdsApp.adGroups().get();   while (adGroupIterator.hasNext()) {     var adGroup = adGroupIterator.next();     Logger.log("adGroup: ")     Logger.log(adGroup.getName());   } } function campaign(){   var campIter = AdsApp.campaigns().get();   while (campIter.hasNext()){     var ads = campIter.next().ads().get();     while(ads.hasNext()){       Logger.log(ads.next().getStatsFor("LAST_30_DAYS"));     }   } } function sheet() {   var sheetURL = "https://docs.google.com/spreadsheets/d/1W0zhRrQa1P7qjQf0eXXw-QzdcPKAlDPiVBOcIVEfDgw/edit#gid=1428103052";   var sheet = SpreadsheetApp.openByUrl(sheetURL); } function main(){   campaign();   adGroup();   productGroup(); } 

I then reached out to the Ads Script support team and found out that it is not possible. But they suggested that I can use Shopping Performance Report, Product Partition Report, shopping_performance_view or product_group_view. They are part of AdWord API, and I do not know how to work with them.

So, I am looking for a Google Ads Script that would help me get a list of products (with detailed statistics) from Googe Ads and I am stuck with how to use the above-mentioned AdWord reporting endpoints to do it.

Here is the list of products in my Google Ads Account. They are 107 products along with their statistics.

Please, help with at least comments, ideas, and suggestions, I can write code but I am not sure what I am missing on

usually we add a script to our website to track conversion for google analytics. Is there any way send the data from plain javascript code such as in the case of Facebook. for example:

'use strict'; const bizSdk = require('facebook-nodejs-business-sdk'); const Content = bizSdk.Content; const CustomData = bizSdk.CustomData; const DeliveryCategory = bizSdk.DeliveryCategory; const EventRequest = bizSdk.EventRequest; const UserData = bizSdk.UserData; const ServerEvent = bizSdk.ServerEvent; const access_token = '<ACCESS_TOKEN>'; const pixel_id = '<ADS_PIXEL_ID>'; const api = bizSdk.FacebookAdsApi.init(access_token); let current_timestamp = Math.floor(new Date() / 1000); const userData = (new UserData())                 .setEmails(['joe@eg.com'])                 .setPhones(['12345678901', '14251234567'])                 // It is recommended to send Client IP and User Agent for Conversions API Events.                 .setClientIpAddress(request.connection.remoteAddress)                 .setClientUserAgent(request.headers['user-agent'])                 .setFbp('fb.1.1558571054389.1098115397')                 .setFbc('fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890'); const content = (new Content())                 .setId('product123')                 .setQuantity(1)                 .setDeliveryCategory(DeliveryCategory.HOME_DELIVERY); const customData = (new CustomData())                 .setContents([content])                 .setCurrency('usd')                 .setValue(123.45); const serverEvent = (new ServerEvent())                 .setEventName('Purchase')                 .setEventTime(current_timestamp)                 .setUserData(userData)                 .setCustomData(customData)                 .setEventSourceUrl('http://jaspers-market.com/product/123')                 .setActionSource('website'); const eventsData = [serverEvent]; const eventRequest = (new EventRequest(access_token, pixel_id))                 .setEvents(eventsData); eventRequest.execute().then(   response => {     console.log('Response: ', response);   },   err => {     console.error('Error: ', err);   } );

or we can do something like: To send new events, make a POST request to this API's /events edge from this path: https://graph.facebook.com/{API_VERSION}/{PIXEL_ID}/events?access_token={TOKEN}. When you post to this edge, Facebook creates new server events.