Adword Script in Google App Scripts - google-apps-script

I am not able to find Adword API support in Google App Script,I can write adword script from adword account but currently i'm handling multiple account(almost 25) what i have to do is go inside individual account and copy my script in that account and adword script have limitation of maximum 15 script can be run by one user at a time, i want to create database of all account at one place that is possible through adword api in java and other programming languages,but i'm quite familiar with Google App script i want to use Adword API in App Script,how can i use UrlFetch() class of Google App Script to use adword api, so that just by replacing client Id of adword account i can get all data at one place(i have access to all account so no need to change username and password).
Thanks in advance for any help and information!

If I understand correctly, the main problem is that you want to to basicaly make a "code library?" So reuse the same bits of code between accounts?
One option is to use the Eval function, as detailed in tip 3 of this article: http://www.ppchero.com/tricks-for-running-adwords-scripts-in-multiple-accounts/. A second example of using this same method is here: http://www.freeadwordsscripts.com/2013/10/use-gdrive-to-load-single-adwords.html
You would then upload this into Google Drive, or point this to the location of the Google Script.
Another option, as detailed in the PPC Hero Article, is to use Google Sheets to pass the variables you need from one script to another. Basically, the SpreadsheetApp function works within all AdWords scripts, so you can use this to pass data along from external sources.

There are some example scripts regarding Adwords associated with these posts:
http://searchengineland.com/four-ways-you-can-benefit-by-using-adwords-scripts-145530
http://googleappsdeveloper.blogspot.co.uk/2012/12/adwords-analysis-in-google-apps-script.html?m=1

Related

Trying to use app script tied to Google Sheet to write to another user's Sheet/Drive

there.
First time poster here. I've been using GAS to build a personal app that takes Telegram input and posts to a Google Sheet. It's a very simple app that helps manage a budget. I'm trying to extend the functionality to allow a couple friends who have expressed interest to post their own transactions to their own Google Sheets hosted on their own Google Accounts.
Right now the only way I can see to do that is to have them "share" their Google Sheet with my user account, which is obviously not preferable. I'd like the app to have authorized access, which would obviously require them to grant the access, but don't want a "shared" sheet.
Is there any way to do this within the Google App Script Editor enviroment? Or do I have to switch everything over to something like Google Cloud? If the latter, can anyone point me toward a tutorial on getting that done?
Thanks in advance.

How can I Find All Uses of a Google Script Library?

I have a Google Script library that is used by at least 100 other scripts (some that are bound to spreadsheets/documents, some that are not). How can I find all of these client scripts that reference my library script?
More specifically, I need to be able to add a new feature into the library that requires new permissions that I (the user) must grant. The client scripts won't run if I just add this feature to the library without granting the permissions to each of the client scripts. So ultimately, I need to give this new permission to each of the clients. And if I knew what scripts were actually using this library, I could do that manually for each one. But I need to URL's or ID's or something for each of those scripts.
Answer:
Unfortunately this is not possible to do.
More Information
It is possible to get a list of standalone Scripts from your Drive, though scripts bound to a file can not be searched for using regular searching methods.
It is possible, using the help of this Google Account page to get a list of all the Apps that have access to your account, though only files you have authorised will appear here, and apps which are not just those created by you in Apps Script will appear there (for example, other add-ons or even Android Apps bound to your account appear here).
A Partial Workaround:
Using Google Apps Script, you can list all Apps Script Projects that you own with help of the MimeType enumeration GOOGLE_APPS_SCRIPT
var scripts = DriveApp.getFilesByType(MimeType.GOOGLE_APPS_SCRIPT);
var arr =[ ];
while (scripts.hasNext()) {
var script = scripts.next();
arr.push(script)
}
Logger.log(arr);
Or even just searching for type:script in Drive, however this only returns a list of scripts that are not bound to a file.
You can then use regular Google Drive search terms to find which of these files contain, for example, a unique method name that the library uses. I am aware this isn't a perfect solution and you would still have to look for projects bound to a file using the above webpage.
Feature Request:
It appears that back in 2014 a feature request for this was made on Google's Issue Tracker, though I would suggest creating another feature request for this here as it was marked as a duplicate of another issue. You can make a feature request under the correct Apps Script component here.
References:
Google Apps Script - Enum MimeType
Google Drive Search Query Terms
Apps with access to your account
Google's Issue Tracker
Feature Request: Listing and searching for container bound scripts
Create an Apps Script Feature Request

How can I create spreadsheet with included gs script by API?

I'd like to manage spreadsheets (uploaded by a client via API) over google engine. I created test spreadsheet extended by functions in .gs script (which works great if I add them via online editor) but I do not know how to apply such a .gs script to every uploaded spreadsheet automatically (possibly via API).
Moreover, I do not want to share this .gs file by publishing it as an extension (because of security policies).
Updated: I also tried copying existing spreadsheet with working gs script and overwriting its spreadsheet data via API (instead of uploading new one) - it's overwritten data successfully but unfortunately lost gs script. Details are described in separate (bounty) question: Custom google app script doesn't work after copying spreadsheet with google java client
So I've even tried copying using plain HTTP methods since I thought it might be a problem with Java SDK but it still didn't work which means that there is some problem at google side (or something is really unclear) with service accounts.
After all I solved the problem with another approach.
First I copy spreadsheet with script attached to it to my service account (as I described in this Custom google app script doesn't work after copying spreadsheet with google java client topic). The file is copied with broken script.
Then I make user authorize using google's oauth (this tutorial shows how https://developers.google.com/identity/protocols/OAuth2WebServer#overview)
And then on his behalf I perform copying.
Finally the file is on his private drive which is the biggest downside of this solution but at least the script works which was my main goal.
Hope it helps ;)
You can publish a google script without it going on the Marketplace. If you make a Google group you can publish in such a way that only members of your google group can see it. If your google group only has you, only you can see it. Then it will be on all of your spread sheets.
The downside being that google will never let you remove it from their server, only unpublish it.
You can create a stand-alone script that is independent of any spreadsheet. This script would contain any methods/functions needed to create and manipulate spreadsheets according to your use case. Furthermore you could deploy the script as a web-app and implement a doGet() or doPost() method. Whenever a user uploads spreadsheet data via API you can call the web app with the information and have it create spreadsheets as needed.

Call Google Spreadsheet script function from external app

I have Google spreadsheet with script attached to it (with the Tools->Script Editor tool).
I want to call one of script function from external Android App. Is it possible? Should I use Spreadsheet API?
Unfortunately, you cannot directly call your script from any external application.
However, you can change it to be a web application, then invoke it via an HTTP GET or POST from almost anywhere, including an Android app.
Insert new rows into Google Spreadsheet via cURL/PHP - HOW? provides an example of a web app that you could adapt.
Should I use Spreadsheet API?
Your question doesn't actually say what it is you want to do, so the answer is "it depends". You still won't be able to invoke an embedded script using the Spreadsheet API, but you will be able to read and write spreadsheet content.
Obviously the answer depends on your usecases, but have you checked the Google Appscript API?
As stated it
provides methods to remotely execute Apps Script functions

Can Google Apps Scripts be flexible enough to handle multiple sheets?

Is it possible with one Google Apps Script published as a Web Application to be flexible enough to connect to different spreadsheets depending on the person or webmaster using the Application?
I saw when working with one of my scripts there are ‘script properties’ and then ‘user properties’ tabs under ‘Project properties’.
I tried to add a property but couldn't get it to Stick
So then I found Google Apps Script ‘Class Properties’ area.
When I think of how these two properties might work, I think of Google Gadgets. A user can add a gadget to her Google Site but can then change or configure the Gadget in the properties area of that gadget
Is this type of functionality possible?
You can configure settings that will allow one script to access the files of the user of the Apps Script. The user needs to log in with their Google account.
You can publish the Apps Script script to run as ANYONE, and Execute the app as: User Accessing the Web App. Which requires the user to log in with their Google Account, and will allow the script to access the users files.
The Properties Service is for storage. It doesn't set or grant permissions. A break down comparison of the different types of Properties is shown at:
Comparison of Property Stores
For the question, 'Can Google Script me modified to run differently depending on who's running it', yes.
For example, you could use the function 'getActiveUser()', and dependent on who the user was, you could set a variable such as 'thisUsersSheet == usersSpreadsheet key', among many other ways to do this.
Whether or not it would be possible to have it replaced site gadgets, that's much more dependent on what you're trying to achieve specifically.
Note: You mention 'Script properties' and 'User Properties' in your question. Stay away from these, they are deprecated.