/// <summary> /// Lists the first page of results for a dimension value. /// </summary> /// <param name="dimensionName">The name of the dimension to retrieve values for.</param> /// <param name="userProfileId">The ID number of the DFA user profile to run this request as.</param> /// <param name="startDate">Values which existed after this start date will be returned.</param> /// <param name="endDate">Values which existed before this end date will be returned.</param> /// <param name="maxPageSize">The maximum page size to retrieve.</param> /// <returns>The first page of dimension values received.</returns> public DimensionValueList Query(string dimensionName, long userProfileId, DateTime startDate, DateTime endDate, int maxPageSize) { Console.WriteLine("================================================================="); Console.WriteLine("Listing available {0} values", dimensionName); Console.WriteLine("================================================================="); // Create a dimension value query which selects available dimension values. var request = new DimensionValueRequest(); request.DimensionName = dimensionName; request.StartDate = DfaReportingDateConverterUtil.convert(startDate); request.EndDate = DfaReportingDateConverterUtil.convert(endDate); var dimensionQuery = service.DimensionValues.Query(request, userProfileId); dimensionQuery.MaxResults = maxPageSize; // Retrieve values and display them. var values = dimensionQuery.Execute(); if (values.Items.Count > 0) { foreach (var dimensionValue in values.Items) { Console.WriteLine("{0} with value \"{1}\" was found.", dimensionName, dimensionValue.Value); } } else { Console.WriteLine("No values found."); } Console.WriteLine(); return(values); }
/// <summary> /// Inserts (creates) a simple Floodlight report for a given Floodlight Configuration ID. /// </summary> /// <param name="userProfileId"> /// The ID number of the DFA user profile to run this request as. /// </param> /// <param name="floodlightConfigId"> /// The Floodlight configuration ID the report is about. /// </param> /// <param name="startDate">The starting date of the report.</param> /// <param name="endDate">The ending date of the report.</param> /// <returns>The newly created report</returns> public Report Insert(long userProfileId, DimensionValue floodlightConfigId, DateTime startDate, DateTime endDate) { Console.WriteLine("================================================================="); Console.WriteLine("Creating a new floodlight report for Floodlight config ID {0}", floodlightConfigId.Value); Console.WriteLine("================================================================="); // Create a report. Report report = new Report(); report.Name = string.Format("API Floodlight Report: Floodlight ID {0}", floodlightConfigId.Value); report.FileName = "api_floodlight_report_files"; // Set the type of report you want to create. Available report types can be found in // the description of the type property: // https://developers.google.com/doubleclick-advertisers/reporting/v1.3/reports report.Type = "FLOODLIGHT"; // Create criteria. var criteria = new Report.FloodlightCriteriaData(); criteria.DateRange = new DateRange { StartDate = DfaReportingDateConverterUtil.convert(startDate), EndDate = DfaReportingDateConverterUtil.convert(endDate) }; // Set the dimensions, metrics, and filters you want in the report. The available // values can be found here: // https://developers.google.com/doubleclick-advertisers/reporting/v1.3/dimensions criteria.Dimensions = new List <SortedDimension> { new SortedDimension { Name = "dfa:floodlightConfigId" }, new SortedDimension { Name = "dfa:activity" }, new SortedDimension { Name = "dfa:advertiser" } }; criteria.MetricNames = new List <string> { "dfa:activityClickThroughConversions", "dfa:activityClickThroughRevenue", "dfa:activityViewThroughConversions", "dfa:activityViewThroughRevenue" }; criteria.DimensionFilters = new List <DimensionValue> { floodlightConfigId }; report.FloodlightCriteria = criteria; Report result = service.Reports.Insert(report, userProfileId).Execute(); Console.WriteLine("Created report with ID \"{0}\" and display name \"{1}\"", result.Id, result.Name); Console.WriteLine(); return(result); }
/// <summary> /// Inserts (creates) a simple standard report for a given advertiser. /// </summary> /// <param name="userProfileId"> /// The ID number of the DFA user profile to run this request as. /// </param> /// <param name="advertiser">The advertiser who the report is about.</param> /// <param name="startDate">The starting date of the report.</param> /// <param name="endDate">The ending date of the report.</param> /// <returns>The newly created report</returns> public Report Insert(long userProfileId, DimensionValue advertiser, DateTime startDate, DateTime endDate) { Console.WriteLine("================================================================="); Console.WriteLine("Creating a new standard report for advertiser {0}%n", advertiser.Value); Console.WriteLine("================================================================="); // Create a report. var report = new Report(); report.Name = string.Format("API Report: Advertiser {0}", advertiser.Value); report.FileName = "api_report_files"; // Set the type of report you want to create. Available report types can be found in //the description of the type property: // https://developers.google.com/doubleclick-advertisers/reporting/v1.3/reports report.Type = "FLOODLIGHT"; report.Type = "STANDARD"; // Create criteria. var criteria = new Report.CriteriaData(); criteria.DateRange = new DateRange { StartDate = DfaReportingDateConverterUtil.convert(startDate), EndDate = DfaReportingDateConverterUtil.convert(endDate) }; // Set the dimensions, metrics, and filters you want in the report. The available // values can be found here: // https://developers.google.com/doubleclick-advertisers/reporting/v1.3/dimensions criteria.Dimensions = new List <SortedDimension> { new SortedDimension { Name = "dfa:advertiser" } }; criteria.MetricNames = new List <string> { "dfa:clicks", "dfa:impressions" }; criteria.DimensionFilters = new List <DimensionValue> { advertiser }; report.Criteria = criteria; Report result = service.Reports.Insert(report, userProfileId).Execute(); Console.WriteLine("Created report with ID \"{0}\" and display name \"{1}\"", result.Id, result.Name); Console.WriteLine(); return(result); }