Hi Everyone,
I'm working on a script to automate monthly reporting of a large account (150+ active campaigns).
The script works except that we can't use the WHERE clause we intended (CampaignName CONTAINS) because we use the ACCOUNT_PERFORMANCE_REPORT and we get the expected error:
"Column 'CampaignName' is not valid for report type ACCOUNT_PERFORMANCE_REPORT. Double-check your SELECT clause. (line 144)"
Here is the code that represents what we want to achieve:
var fields = {
"Clicks":"Clicks", "Impr.":"Impressions", "CTR":"Ctr", "Avg. CPC":"AverageCpc", "Cost":"Cost",
"Converted clicks":"Conversions", "CPA":"CostPerConversion", "CR":"ConversionRate", "View-through conv.":"ViewThroughConversions",
"Conversions":"ConversionsManyPerClick"
};
var awql = "SELECT " + fieldsValues.join(", ") + " " +
"FROM ACCOUNT_PERFORMANCE_REPORT " +
"WHERE CampaignName CONTAINS " + SETTINGS[currentActiveSheet.getName()] + " " +
"DURING " + dateRanges[i];
Each dateRange represents a month.
We need to use a CampaignName filter because we need to pull out only the information for specific campaigns (identified by name) and get one row per awql request. Each AWQL request feeds different data to each sheet depending on what was the campaignName that was searched.
I know we can use other Report Types that have the CampaignName field (like the CAMPAIGN_PERFORMANCE_REPORT) but this report type gives us multiple rows per awql request, with information specific to each campaign but we need to get only one row. For example, for each month, get data for all campaigns that have "USA" in their name and put the single row obtained into the "USA" sheet. Then pull data for all campaigns that have "France" in their name and put the single row obtained into the "France" sheet., etc.
Is there a way to do this? For example is it possible to use a campaignName filter after the first AWQL request to request the wanted data? I think it might be possible to use the
campaign selector but don't know what would be the best way to combine these 2 filtering methods (if it's possible at all).
Thank you very much in advance,
Marc.