/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); string reportName = _T("INSERT_REPORT_NAME_HERE"); // Create a date range to report on. DateRange dateRange = new DateRange(); dateRange.RelativeDateRange = "YESTERDAY"; // Create a dimension to report on. SortedDimension dimension = new SortedDimension(); dimension.Name = "dfa:campaign"; // Create the criteria for the report. Report.CriteriaData criteria = new Report.CriteriaData(); criteria.DateRange = dateRange; criteria.Dimensions = new List<SortedDimension>() { dimension }; criteria.MetricNames = new List<string>() { "dfa:clicks" }; // Create the report. Report report = new Report(); report.Criteria = criteria; report.Name = reportName; report.Type = "STANDARD"; // Insert the report. Report result = service.Reports.Insert(report, profileId).Execute(); // Display the new report ID. Console.WriteLine("Standard report with ID {0} was created.", result.Id); }
private void DefineReportCriteria(Report report) { // Define a date range to report on. This example uses explicit start and // end dates to mimic the "LAST_30_DAYS" relative date range. DateRange dateRange = new DateRange(); dateRange.EndDate = DateTime.Now.ToString("yyyy-MM-dd"); dateRange.StartDate = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd"); // Create a report criteria. SortedDimension dimension = new SortedDimension(); dimension.Name = "dfa:advertiser"; Report.CriteriaData criteria = new Report.CriteriaData(); criteria.DateRange = dateRange; criteria.Dimensions = new List <SortedDimension>() { dimension }; criteria.MetricNames = new List <string>() { "dfa:clicks", "dfa:impressions" }; // Add the criteria to the report resource. report.Criteria = criteria; Console.WriteLine("\nAdded report criteria:\n{0}", JsonConvert.SerializeObject(criteria)); }
/// <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.1/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.1/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; }
/// <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); }
/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); string reportName = _T("INSERT_REPORT_NAME_HERE"); // Create a date range to report on. DateRange dateRange = new DateRange(); dateRange.RelativeDateRange = "YESTERDAY"; // Create a dimension to report on. SortedDimension dimension = new SortedDimension(); dimension.Name = "dfa:campaign"; // Create the criteria for the report. Report.CriteriaData criteria = new Report.CriteriaData(); criteria.DateRange = dateRange; criteria.Dimensions = new List <SortedDimension>() { dimension }; criteria.MetricNames = new List <string>() { "dfa:clicks" }; // Create the report. Report report = new Report(); report.Criteria = criteria; report.Name = reportName; report.Type = "STANDARD"; // Insert the report. Report result = service.Reports.Insert(report, profileId).Execute(); // Display the new report ID. Console.WriteLine("Standard report with ID {0} was created.", result.Id); }