How to get Date as a segment in Final_URL_Report in Adwords API - google-ads-api

Executing my code (using the Google Adwords Library to build an oauth user etc) works when using a query with Month as a segment
String query = "SELECT EffectiveFinalUrl, Cost, Clicks, Impressions,
Month FROM FINAL_URL_REPORT";
But it aggregates across all time, split into months. I am trying to pull in the data as daily aggregates. The documentation has both Month and Date (splitting data into yyyy-MM-dd) as a segment you can include in the query, but Date does not work.
String query = "SELECT EffectiveFinalUrl, Cost, Clicks, Impressions,
Date FROM FINAL_URL_REPORT";
Results in Error 400: Bad Request.
Am I missing something in the documentation that tells me how to resolve this?
Adwords Final_URL_Report Documentation

Try set a date range by adding something like DURING ... to your query.

Related

Is it possible to get Google Ads metric data on a daily basis within a date range?

I'm trying to display a bar chart that shows the performance of a Google ad between the 1st of March to the 31st of March. Each bar indicates a day in that range.
At the moment my query looks like
SELECT
ad_group_ad.ad.id,
ad_group_ad.ad.name,
metrics.average_cost
FROM
ad_group_ad
WHERE
segments.date
BETWEEN '2021-03-01' AND '2021-03-31' AND ad_group_ad.status = 'ENABLED'
The data I get back are totals within the range. I need the totals of each day within the range. Is there a way to get this information in one request?
I found a segment that segments the data into weekly slices.
SELECT
ad_group_ad.ad.id,
ad_group_ad.ad.name,
metrics.average_cost,
segments.week,
segments.keyword.info.text
FROM
ad_group_ad
WHERE
segments.date
BETWEEN '2021-03-01' AND '2021-03-31' AND ad_group_ad.status = 'ENABLED'
https://developers.google.com/google-ads/api/fields/v6/ad_group_ad#segments.week
segments.day is not documented but I can see on the google ads dashboard you can segment by days if the date range isn't greater than 16 days. I'm going to keep snooping around and see if I can find how that's done.
You just need to add segments.date to your select.

How do I pull the month from text strings in this Twilio format 2019-08-22 06:12:58 MDT?

I am using the Twilio log file to crunch some data and need to convert the Twilio format for dates into something that Google Sheets can recognize as a date so I can then extract what month the date is referring to. I think that first, the text string has to be converted to be a better format and then I can use one of Google Sheets functions to extra the month. Currently, this is the format in the log file:
"2019-08-22 06:12:58 MDT"
I used GoogleSheets TIMEVALUE and TEXT functions.
=TIMEVALUE(I2)
and
=text(I2,”mmmm”)
I get "Formula Parse Error"
The timezone stamp is messing up the Google formulas for you.
So you may want to try getting rid of that with something like this:
=text(index(split(I2," "),,1),"mmmm")
The split function breaks up the logged time stamp into 2019-08-22 | 06:12:58 | MDT across three columns.
And the index function then gets the just the first column - the date bit from there.
And then the text function gets the month name out of the date.
you can use:
=TEXT(LEFT(A1, 10), "mmmm")
and in array it would be:
=ARRAYFORMULA(TEXT(LEFT(A1:A, 10), "mmmm"))

Yahoo historic intraday stock data via YQL (just like chart api)?

I know I can get historical intraday data (up 15 days) using chart api as follows
http://chartapi.finance.yahoo.com/instrument/1.1/GOOG/chartdata;type=quote;range=5d/xml/
Using YQL, and
env 'store://datatables.org/alltableswithkeys'
I can use .quotes and .historicaldata:
select * from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT")
select * from yahoo.finance.historicaldata where symbol in ("YHOO","AAPL","GOOG","MSFT") and startDate = "2012-09-13" and endDate = "2012-09-13"
What I can't figure out is how to use a YQL statement to obtain historical intraday data (like using chartapi; probably limited to a few days in range).
Is there any documentation about this somewhere?
Alex

OData: Date "Greater Than" filter

Is there a way to return a series of records in OData by specifying a "Date greater than xxxxx" filter...but using a Date that was previously obtained form an OData feed?
Use Case: Pretend that I want to build a web page that displays a list of the most recently completed online orders. This is what I'm aiming for:
Load the page
Hit my OData service asynchronously, returning the last 100 orders (ordering by date descending so that the most recently completed order shows up first)
Build the HTML on the page using the OData data
Store the MAX date into a global variable (looks like this: /Date(1338336000000)/)
Hit the OData service on a 30 second interval but this time specify a filter to only return records where the order date is greater than the previous MAX Date. In this case: /Date(1338336000000)/
If any records are returned, build the HTML for those records and prepend the items to the previously loaded items.
Where I am struggling is in specifying the Date "greater than" filter. For some reason, the date filters in OData do not seem to play very nice with OData's own native date format. Do I need to convert the date originally obtained into a different format that can be used for filtering?
I want to do something like this:
http://mydomain/Services/v001.svc/Orders?$filter=close_dt%20gt%201338336000000
FYI: I'm using V2
Figured this out.
OData V2 out-of-the-box returns dates out of SQL in JSON Date format like so:
/Date(1338282808000)/
However, in order to use a date as a filter within an OData call, your date has to be in EDM format, looking like this:
2012-05-29T09:13:28
So, I needed to get the date from my initial OData call, then convert it to the EDM format for use in my subsequent OData calls, which look like this:
/Services/v001.svc/Orders?$filter=close_dt gt DateTime'2012-05-29T09:13:28'
I ended up creating a javascript function that does the formatting switcharoo:
function convertJSONDate(jsonDate, returnFormat) {
var myDate = new Date(jsonDate.match(/\d+/)[0] * 1);
myDate.add(4).hours(); //using {date.format.js} to add time to compensate for timezone offset
return myDate.format(returnFormat); //using {date.format.js} plugin to format :: EDM FORMAT='yyyy-MM-ddTHH:mm:ss'
}
A couple of notes:
The JSON format does not seem to adjust for timezone, so the date returned does not match the date I see in my database. So I had to add time manually to compensate (someone please explain this).
I am using the date.format.js plugin which you can download here for formatting the date and adding time.
In OData V4 date filtering format has changed to $filter=close_dt gt 2006-12-30T23:59:59.99Z
For example
http://services.odata.org/V4/OData/OData.svc/Products?$filter=ReleaseDate%20gt%202006-12-30T23:59:59.99Z
For previous versions of OData see previous answers
If you use the datetime logic, you can do lt or gt.
e.g.
...mydomain/Services/v001.svc/Orders?$filter=close_dt gt datetime'20141231'
Just an FYI: in V3 of the protocol the non-tick-based datetime format is now the default:
http://services.odata.org/Experimental/OData/OData.svc/Products%280%29?$format=application/json;odata=verbose&$select=ReleaseDate
..."ReleaseDate":"1992-01-01T00:00:00"...
I will just try to make the answer of #avitenberg more clear:
var date= DateTime.Now;
//Convert time to UTC format
$"filter={close_dt} gt {date:yyyy-MM-ddTHH:mm:ss.FFFZ}";
See Microsoft:

issue to query data filtered by Date from fusion table

I'm trying to write a small javascript code to query data filtered by date.
If I write the following sentence in my browser, I can get data :
"http://www.google.com/fusiontables/gvizdata?tq=SELECT Date, Poids FROM 3049883"
but if I write the same thing, except I want only data after a certain date :
"http://www.google.com/fusiontables/gvizdata?tq=SELECT Date, Poids FROM 3049883 WHERE Date > 2/29/12"
From the SQL-like API, https://developers.google.com/fusiontables/docs/developers_reference#Select, it should work
I get an error witch is "'internal_error', message:'Could not parse query'"
-Date is a DATETIME format in my fusion table.
-I've tried different format, but I can not get data.
What am I doing wrong?
Thank you very much for your help.
The Date value must be quoted and the format is MM/dd/yy so you must pad single digits with leading zeros.
I had success with:
select Date,Poids from 3049883 where Date >= '02/29/12'
Note: I did not test with gvizdata, just with the FT JSONP API

Resources