AWQL Query based on multiple date ranges
up vote
0
down vote
favorite
I'm pulling some simple stats from the AdWords API and I want to enhance it to bring back YoY data.
I want to get total clicks, impressions, ctr for a month in 2017 and 2018.
My Goal: pull this data in 1 call...I don't want to have to call the API twice every time I need to compare 2 date ranges.
I'm not certain AWQL can cater for this though. Can anyone advise? Here's my code...
var googleService = adClient.GetService(Services.V0.GoogleAdsService);
string query = @"SELECT date, metrics.impressions, metrics.clicks, metrics.ctr
FROM campaign
WHERE date BETWEEN '2018-10-01' AND '2018-10-31'
OR date BETWEEN '2017-10-01' AND '2017-10-31' // <- this bit is not working
LIMIT 50";
PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> response =
googleService.Search(customerId.ToString(), query);
if(response!=null && response.Count()>0)
//then (just as an example), I could extract my info like...
long clicks2018 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Clicks));
long impressions2018 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Impressions));
double ctr2018 = Convert.ToDouble(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Ctr));
long clicks2017 = Convert.ToInt64(response.Where(n=>n.Date.StartsWith("2017")).Sum(n => n.Metrics.Clicks));
long impressions2017 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2017")).Sum(n => n.Metrics.Impressions));
double ctr2017 = Convert.ToDouble(response.Where(n => n.Date.StartsWith("2017")).Sum(n => n.Metrics.Ctr));
c# google-adwords adwords-api-v201109 awql
add a comment |
up vote
0
down vote
favorite
I'm pulling some simple stats from the AdWords API and I want to enhance it to bring back YoY data.
I want to get total clicks, impressions, ctr for a month in 2017 and 2018.
My Goal: pull this data in 1 call...I don't want to have to call the API twice every time I need to compare 2 date ranges.
I'm not certain AWQL can cater for this though. Can anyone advise? Here's my code...
var googleService = adClient.GetService(Services.V0.GoogleAdsService);
string query = @"SELECT date, metrics.impressions, metrics.clicks, metrics.ctr
FROM campaign
WHERE date BETWEEN '2018-10-01' AND '2018-10-31'
OR date BETWEEN '2017-10-01' AND '2017-10-31' // <- this bit is not working
LIMIT 50";
PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> response =
googleService.Search(customerId.ToString(), query);
if(response!=null && response.Count()>0)
//then (just as an example), I could extract my info like...
long clicks2018 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Clicks));
long impressions2018 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Impressions));
double ctr2018 = Convert.ToDouble(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Ctr));
long clicks2017 = Convert.ToInt64(response.Where(n=>n.Date.StartsWith("2017")).Sum(n => n.Metrics.Clicks));
long impressions2017 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2017")).Sum(n => n.Metrics.Impressions));
double ctr2017 = Convert.ToDouble(response.Where(n => n.Date.StartsWith("2017")).Sum(n => n.Metrics.Ctr));
c# google-adwords adwords-api-v201109 awql
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm pulling some simple stats from the AdWords API and I want to enhance it to bring back YoY data.
I want to get total clicks, impressions, ctr for a month in 2017 and 2018.
My Goal: pull this data in 1 call...I don't want to have to call the API twice every time I need to compare 2 date ranges.
I'm not certain AWQL can cater for this though. Can anyone advise? Here's my code...
var googleService = adClient.GetService(Services.V0.GoogleAdsService);
string query = @"SELECT date, metrics.impressions, metrics.clicks, metrics.ctr
FROM campaign
WHERE date BETWEEN '2018-10-01' AND '2018-10-31'
OR date BETWEEN '2017-10-01' AND '2017-10-31' // <- this bit is not working
LIMIT 50";
PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> response =
googleService.Search(customerId.ToString(), query);
if(response!=null && response.Count()>0)
//then (just as an example), I could extract my info like...
long clicks2018 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Clicks));
long impressions2018 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Impressions));
double ctr2018 = Convert.ToDouble(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Ctr));
long clicks2017 = Convert.ToInt64(response.Where(n=>n.Date.StartsWith("2017")).Sum(n => n.Metrics.Clicks));
long impressions2017 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2017")).Sum(n => n.Metrics.Impressions));
double ctr2017 = Convert.ToDouble(response.Where(n => n.Date.StartsWith("2017")).Sum(n => n.Metrics.Ctr));
c# google-adwords adwords-api-v201109 awql
I'm pulling some simple stats from the AdWords API and I want to enhance it to bring back YoY data.
I want to get total clicks, impressions, ctr for a month in 2017 and 2018.
My Goal: pull this data in 1 call...I don't want to have to call the API twice every time I need to compare 2 date ranges.
I'm not certain AWQL can cater for this though. Can anyone advise? Here's my code...
var googleService = adClient.GetService(Services.V0.GoogleAdsService);
string query = @"SELECT date, metrics.impressions, metrics.clicks, metrics.ctr
FROM campaign
WHERE date BETWEEN '2018-10-01' AND '2018-10-31'
OR date BETWEEN '2017-10-01' AND '2017-10-31' // <- this bit is not working
LIMIT 50";
PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> response =
googleService.Search(customerId.ToString(), query);
if(response!=null && response.Count()>0)
//then (just as an example), I could extract my info like...
long clicks2018 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Clicks));
long impressions2018 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Impressions));
double ctr2018 = Convert.ToDouble(response.Where(n => n.Date.StartsWith("2018")).Sum(n => n.Metrics.Ctr));
long clicks2017 = Convert.ToInt64(response.Where(n=>n.Date.StartsWith("2017")).Sum(n => n.Metrics.Clicks));
long impressions2017 = Convert.ToInt64(response.Where(n => n.Date.StartsWith("2017")).Sum(n => n.Metrics.Impressions));
double ctr2017 = Convert.ToDouble(response.Where(n => n.Date.StartsWith("2017")).Sum(n => n.Metrics.Ctr));
c# google-adwords adwords-api-v201109 awql
c# google-adwords adwords-api-v201109 awql
edited 2 days ago
asked 2 days ago
scgough
2,69911033
2,69911033
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225039%2fawql-query-based-on-multiple-date-ranges%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password