Remarketing Samples

The code samples below provide examples of common remarketing functions using the AdWords API. Client Library.

Add audience

// Copyright 2017, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Api.Ads.AdWords.Lib;
using Google.Api.Ads.AdWords.v201705;

using System;
using System.Collections.Generic;
using System.IO;

namespace Google.Api.Ads.AdWords.Examples.CSharp.v201705 {
  /// <summary>
  /// This code example illustrates how to create a user list a.k.a. audience.
  /// </summary>
  public class AddAudience : ExampleBase {
    /// <summary>
    /// Main method, to run this code example as a standalone application.
    /// </summary>
    /// <param name="args">The command line arguments.</param>
    public static void Main(string[] args) {
      AddAudience codeExample = new AddAudience();
      Console.WriteLine(codeExample.Description);
      try {
        codeExample.Run(new AdWordsUser());
      } catch (Exception e) {
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e));
      }
    }

    /// <summary>
    /// Returns a description about the code example.
    /// </summary>
    public override string Description {
      get {
        return "This code example illustrates how to create a user list a.k.a. audience.";
      }
    }

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    public void Run(AdWordsUser user) {
      // Get the UserListService.
      AdwordsUserListService userListService =
          (AdwordsUserListService) user.GetService(AdWordsService.v201705.AdwordsUserListService);

      // Get the ConversionTrackerService.
      ConversionTrackerService conversionTrackerService =
          (ConversionTrackerService)user.GetService(AdWordsService.v201705.
              ConversionTrackerService);

      BasicUserList userList = new BasicUserList();
      userList.name = "Mars cruise customers #" + ExampleUtilities.GetRandomString();
      userList.description = "A list of mars cruise customers in the last year.";
      userList.status = UserListMembershipStatus.OPEN;
      userList.membershipLifeSpan = 365;

      UserListConversionType conversionType = new UserListConversionType();
      conversionType.name = userList.name;
      userList.conversionTypes = new UserListConversionType[] {conversionType};

      // Optional: Set the user list status.
      userList.status = UserListMembershipStatus.OPEN;

      // Create the operation.
      UserListOperation operation = new UserListOperation();
      operation.operand = userList;
      operation.@operator = Operator.ADD;

      try {
        // Add the user list.
        UserListReturnValue retval = userListService.mutate(new UserListOperation[] {operation});

        UserList[] userLists = null;
        if (retval != null && retval.value != null) {
          userLists = retval.value;
          // Get all conversion snippets
          List<string> conversionIds = new List<string>();
          foreach (BasicUserList newUserList in userLists) {
            if (newUserList.conversionTypes != null) {
              foreach (UserListConversionType newConversionType in newUserList.conversionTypes) {
                conversionIds.Add(newConversionType.id.ToString());
              }
            }
          }

          Dictionary<long, ConversionTracker> conversionsMap =
              new Dictionary<long, ConversionTracker>();

          if (conversionIds.Count > 0) {
            // Create the selector.
            Selector selector = new Selector() {
              fields = new string[] { ConversionTracker.Fields.Id },
              predicates = new Predicate[] {
                Predicate.In(ConversionTracker.Fields.Id, conversionIds)
              }
            };

            // Get all conversion trackers.
            ConversionTrackerPage page = conversionTrackerService.get(selector);

            if (page != null && page.entries != null) {
              foreach (ConversionTracker tracker in page.entries) {
                conversionsMap[tracker.id] = tracker;
              }
            }
          }

          // Display the results.
          foreach (BasicUserList newUserList in userLists) {
            Console.WriteLine("User list with name '{0}' and id '{1}' was added.",
                newUserList.name, newUserList.id);

            // Display user list associated conversion code snippets.
            if (newUserList.conversionTypes != null) {
              foreach (UserListConversionType userListConversionType in
                  newUserList.conversionTypes) {
                if (conversionsMap.ContainsKey(userListConversionType.id)) {
                  AdWordsConversionTracker conversionTracker =
                      (AdWordsConversionTracker) conversionsMap[userListConversionType.id];
                  Console.WriteLine("Conversion type code snippet associated to the list:\n{0}\n",
                      conversionTracker.snippet);
                } else {
                  throw new Exception("Failed to associate conversion type code snippet.");
                }
              }
            }
          }
        } else {
          Console.WriteLine("No user lists (a.k.a. audiences) were added.");
        }
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to add user lists (a.k.a. audiences).", e);
      }
    }
  }
}

Add conversion tracker

// Copyright 2017, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Api.Ads.AdWords.Lib;
using Google.Api.Ads.AdWords.v201705;

using System;
using System.Collections.Generic;
using System.IO;

namespace Google.Api.Ads.AdWords.Examples.CSharp.v201705 {
  /// <summary>
  /// This code example adds an AdWords conversion tracker.
  /// </summary>
  public class AddConversionTracker : ExampleBase {
    /// <summary>
    /// Main method, to run this code example as a standalone application.
    /// </summary>
    /// <param name="args">The command line arguments.</param>
    public static void Main(string[] args) {
      AddConversionTracker codeExample = new AddConversionTracker();
      Console.WriteLine(codeExample.Description);
      try {
        codeExample.Run(new AdWordsUser());
      } catch (Exception e) {
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e));
      }
    }

    /// <summary>
    /// Returns a description about the code example.
    /// </summary>
    public override string Description {
      get {
        return "This code example adds an AdWords conversion tracker.";
      }
    }

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    public void Run(AdWordsUser user) {
      // Get the ConversionTrackerService.
      ConversionTrackerService conversionTrackerService =
          (ConversionTrackerService)user.GetService(AdWordsService.v201705.
              ConversionTrackerService);

      // Create Adwords conversion tracker.
      AdWordsConversionTracker conversionTracker = new AdWordsConversionTracker();
      conversionTracker.name = "Earth to Mars Cruises Conversion #" +
          ExampleUtilities.GetRandomString();
      conversionTracker.category = ConversionTrackerCategory.DEFAULT;
      conversionTracker.textFormat = AdWordsConversionTrackerTextFormat.HIDDEN;

      // Set optional fields.
      conversionTracker.status = ConversionTrackerStatus.ENABLED;
      conversionTracker.viewthroughLookbackWindow = 15;
      conversionTracker.conversionPageLanguage = "en";
      conversionTracker.backgroundColor = "#0000FF";
      conversionTracker.defaultRevenueValue = 23.41;
      conversionTracker.alwaysUseDefaultRevenueValue = true;

      // Create the operation.
      ConversionTrackerOperation operation = new ConversionTrackerOperation();
      operation.@operator = Operator.ADD;
      operation.operand = conversionTracker;

      try {
        // Add conversion tracker.
        ConversionTrackerReturnValue retval = conversionTrackerService.mutate(
            new ConversionTrackerOperation[] {operation});

        // Display the results.
        if (retval != null && retval.value != null && retval.value.Length > 0) {
          ConversionTracker newConversionTracker = retval.value[0];
          Console.WriteLine("Conversion tracker with id '{0}', name '{1}', status '{2}', " +
              "category '{3}' was added.", newConversionTracker.id, newConversionTracker.name,
              newConversionTracker.status, newConversionTracker.category);
        } else {
          Console.WriteLine("No conversion trackers were added.");
        }
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to add conversion tracker.", e);
      }
    }
  }
}

Add rule-based user list

// Copyright 2017, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using Google.Api.Ads.AdWords.Lib;
using Google.Api.Ads.AdWords.v201705;

namespace Google.Api.Ads.AdWords.Examples.CSharp.v201705 {

  /// <summary>
  /// This code example adds two rule-based remarketing user lists: one with no
  /// site visit date restrictions, and another that will only include users
  /// who visit your site in the next six months. See
  /// https://developers.google.com/adwords/api/docs/guides/rule-based-remarketing
  /// to learn more about rule based remarketing.
  /// </summary>
  public class AddRuleBasedRemarketingList : ExampleBase {
    private const string DATE_FORMAT_STRING = "yyyyMMdd";

    /// <summary>
    /// Main method, to run this code example as a standalone application.
    /// </summary>
    /// <param name="args">The command line arguments.</param>
    public static void Main(string[] args) {
      AddRuleBasedRemarketingList codeExample = new AddRuleBasedRemarketingList();
      Console.WriteLine(codeExample.Description);
      try {
        codeExample.Run(new AdWordsUser());
      } catch (Exception e) {
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e));
      }
    }

    /// <summary>
    /// Returns a description about the code example.
    /// </summary>
    public override string Description {
      get {
        return "This code example adds two rule-based remarketing user lists: one with no " +
            "site visit date restrictions, and another that will only include users who " +
            "visit your site in the next six months. See " +
            "https://developers.google.com/adwords/api/docs/guides/rule-based-remarketing to " +
            "learn more about rule based remarketing.";
      }
    }

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    public void Run(AdWordsUser user) {
      // Get the UserListService.
      AdwordsUserListService userListService =
          (AdwordsUserListService) user.GetService(AdWordsService.v201705.AdwordsUserListService);

      // First rule item group - users who visited the checkout page and had
      // more than one item in their shopping cart.
      StringRuleItem checkoutStringRuleItem = new StringRuleItem();
      checkoutStringRuleItem.key = new StringKey();
      checkoutStringRuleItem.key.name = "ecomm_pagetype";
      checkoutStringRuleItem.op = StringRuleItemStringOperator.EQUALS;
      checkoutStringRuleItem.value = "checkout";

      RuleItem checkoutRuleItem = new RuleItem();
      checkoutRuleItem.Item = checkoutStringRuleItem;

      NumberRuleItem cartSizeNumberRuleItem = new NumberRuleItem();
      cartSizeNumberRuleItem.key = new NumberKey();
      cartSizeNumberRuleItem.key.name = "cartsize";
      cartSizeNumberRuleItem.op = NumberRuleItemNumberOperator.GREATER_THAN;
      cartSizeNumberRuleItem.value = 1;

      RuleItem cartSizeRuleItem = new RuleItem();
      cartSizeRuleItem.Item = cartSizeNumberRuleItem;

      // Combine the two rule items into a RuleItemGroup so AdWords will AND
      // their rules together.
      RuleItemGroup checkoutMultipleItemGroup = new RuleItemGroup();
      checkoutMultipleItemGroup.items = new RuleItem[] { checkoutRuleItem, cartSizeRuleItem };

      // Second rule item group - users who check out within the next 3 months.
      DateRuleItem startDateDateRuleItem = new DateRuleItem();
      startDateDateRuleItem.key = new DateKey();
      startDateDateRuleItem.key.name = "checkoutdate";
      startDateDateRuleItem.op = DateRuleItemDateOperator.AFTER;
      startDateDateRuleItem.value = DateTime.Now.ToString(DATE_FORMAT_STRING);
      RuleItem startDateRuleItem = new RuleItem();
      startDateRuleItem.Item = startDateDateRuleItem;

      DateRuleItem endDateDateRuleItem = new DateRuleItem();
      endDateDateRuleItem.key = new DateKey();
      endDateDateRuleItem.key.name = "checkoutdate";
      endDateDateRuleItem.op = DateRuleItemDateOperator.BEFORE;
      endDateDateRuleItem.value = DateTime.Now.AddMonths(3).ToString(DATE_FORMAT_STRING);
      RuleItem endDateRuleItem = new RuleItem();
      endDateRuleItem.Item = endDateDateRuleItem;

      // Combine the date rule items into a RuleItemGroup.
      RuleItemGroup checkedOutNextThreeMonthsItemGroup = new RuleItemGroup();
      checkedOutNextThreeMonthsItemGroup.items =
          new RuleItem[] { startDateRuleItem, endDateRuleItem };

      // Combine the rule item groups into a Rule so AdWords knows how to apply the rules.
      Rule rule = new Rule();
      rule.groups = new RuleItemGroup[] {checkoutMultipleItemGroup,
          checkedOutNextThreeMonthsItemGroup};

      // ExpressionRuleUserLists can use either CNF Or DNF For matching. CNF means
      // 'at least one item in each rule item group must match', and DNF means 'at
      // least one entire rule item group must match'.
      // DateSpecificRuleUserList only supports DNF. You can also omit the rule
      // type altogether To Default To DNF.
      rule.ruleType = UserListRuleTypeEnumsEnum.DNF;

      // Create the user list with no restrictions on site visit date.
      ExpressionRuleUserList expressionUserList = new ExpressionRuleUserList();
      expressionUserList.name = "Expression based user list created at " + DateTime.Now.ToString(
          "yyyyMMdd_HHmmss");
      expressionUserList.description = "Users who checked out in three month window OR visited " +
          "the checkout page with more than one item in their cart.";
      expressionUserList.rule = rule;

      // Optional: Set the prepopulationStatus to REQUESTED to include past users
      // in the user list.
      expressionUserList.prepopulationStatus = RuleBasedUserListPrepopulationStatus.REQUESTED;

      // Create the user list restricted to users who visit your site within
      // the next six months.
      DateTime startDate = DateTime.Now;
      DateTime endDate = startDate.AddMonths(6);

      DateSpecificRuleUserList dateUserList = new DateSpecificRuleUserList();
      dateUserList.name = "Date rule user list created at " +
          DateTime.Now.ToString("yyyyMMdd_HHmmss");
      dateUserList.description = String.Format("Users who visited the site between {0} and " +
          "{1} and checked out in three month window OR visited the checkout page " +
          "with more than one item in their cart.", startDate.ToString(DATE_FORMAT_STRING),
          endDate.ToString(DATE_FORMAT_STRING));
      dateUserList.rule = rule;

      // Set the start and end dates of the user list.
      dateUserList.startDate = startDate.ToString(DATE_FORMAT_STRING);
      dateUserList.endDate = endDate.ToString(DATE_FORMAT_STRING);

      // Create operations to add the user lists.
      List<UserListOperation> operations = new List<UserListOperation>();
      foreach (UserList userList in new UserList[] { expressionUserList, dateUserList }) {
        UserListOperation operation = new UserListOperation();
        operation.operand = userList;
        operation.@operator = Operator.ADD;
        operations.Add(operation);
      }

      try {
        // Submit the operations.
        UserListReturnValue result = userListService.mutate(operations.ToArray());

        // Display the results.
        foreach (UserList userListResult in result.value) {
          Console.WriteLine("User list added with ID {0}, name '{1}', status '{2}', " +
              "list type '{3}', accountUserListStatus '{4}', description '{5}'.",
              userListResult.id,
              userListResult.name,
              userListResult.status,
              userListResult.listType,
              userListResult.accountUserListStatus,
              userListResult.description);
        }
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to add rule based user lists.", e);
      }
    }
  }
}

Upload offline conversions

// Copyright 2017, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Api.Ads.AdWords.Lib;
using Google.Api.Ads.AdWords.v201705;

using System;
using System.Collections.Generic;
using System.IO;

namespace Google.Api.Ads.AdWords.Examples.CSharp.v201705 {
  /// <summary>
  /// This code example imports offline conversion values for specific clicks to
  /// your account. To get Google Click ID for a click, run
  /// CLICK_PERFORMANCE_REPORT. To set up a conversion tracker, run the
  /// AddConversionTracker.cs example.
  /// </summary>
  public class UploadOfflineConversions : ExampleBase {
    /// <summary>
    /// Main method, to run this code example as a standalone application.
    /// </summary>
    /// <param name="args">The command line arguments.</param>
    public static void Main(string[] args) {
      string conversionName = "INSERT_CONVERSION_NAME_HERE";
      // GCLID needs to be newer than 30 days.
      string gClId = "INSERT_GOOGLE_CLICK_ID_HERE";
      //  The conversion time should be higher than the click time.
      string conversionTime = "INSERT_CONVERSION_TIME_HERE";
      double conversionValue = double.Parse("INSERT_CONVERSION_VALUE_HERE");

      UploadOfflineConversions codeExample = new UploadOfflineConversions();
      Console.WriteLine(codeExample.Description);
      try {
        codeExample.Run(new AdWordsUser(), conversionName, gClId, conversionTime, conversionValue);
      } catch (Exception e) {
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e));
      }
    }

    /// <summary>
    /// Returns a description about the code example.
    /// </summary>
    public override string Description {
      get {
        return "This code example imports offline conversion values for specific clicks to " +
          "your account. To get Google Click ID for a click, run CLICK_PERFORMANCE_REPORT. " +
            " To set up a conversion tracker, run the AddConversionTracker.cs example.";
      }
    }

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="conversionName">The name of the upload conversion to be
    /// created.</param>
    /// <param name="gClid">The Google Click ID of the click for which offline
    /// conversions are uploaded.</param>
    /// <param name="conversionValue">The conversion value to be uploaded.
    /// </param>
    /// <param name="conversionTime">The conversion time, in yyyymmdd hhmmss
    /// format.</param>
    public void Run(AdWordsUser user, String conversionName, String gClid, String conversionTime,
        double conversionValue) {
       // Get the OfflineConversionFeedService.
      OfflineConversionFeedService offlineConversionFeedService =
          (OfflineConversionFeedService) user.GetService(
              AdWordsService.v201705.OfflineConversionFeedService);

      try {
        // Associate offline conversions with the existing named conversion tracker. If
        // this tracker was newly created, it may be a few hours before it can accept
        // conversions.
        OfflineConversionFeed feed = new OfflineConversionFeed();
        feed.conversionName = conversionName;
        feed.conversionTime = conversionTime;
        feed.conversionValue = conversionValue;
        feed.googleClickId = gClid;

        OfflineConversionFeedOperation offlineConversionOperation =
            new OfflineConversionFeedOperation();
        offlineConversionOperation.@operator = Operator.ADD;
        offlineConversionOperation.operand = feed;

        OfflineConversionFeedReturnValue offlineConversionRetval =
            offlineConversionFeedService.mutate(
                new OfflineConversionFeedOperation[] {offlineConversionOperation});

        OfflineConversionFeed newFeed = offlineConversionRetval.value[0];

        Console.WriteLine("Uploaded offline conversion value of {0} for Google Click ID = " +
            "'{1}' to '{2}'.", newFeed.conversionValue, newFeed.googleClickId,
            newFeed.conversionName);
      } catch (Exception e) {
        throw new System.ApplicationException("Failed upload offline conversions.", e);
      }
    }
  }
}

Upload offline call conversions

// Copyright 2017, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Api.Ads.AdWords.Lib;
using Google.Api.Ads.AdWords.v201705;

using System;

namespace Google.Api.Ads.AdWords.Examples.CSharp.v201705 {

  /// <summary>
  /// This code example imports offline call conversion values for calls related to the
  /// ads in your account.
  /// </summary>
  public class UploadOfflineCallConversions : ExampleBase {

    /// <summary>
    /// Main method, to run this code example as a standalone application.
    /// </summary>
    /// <param name="args">The command line arguments.</param>
    public static void Main(string[] args) {
      string conversionName = "INSERT_CONVERSION_NAME_HERE";

      // For times use the format yyyyMMdd HHmmss tz. For more details on formats, see:
      // https://developers.google.com/adwords/api/docs/appendix/codes-formats#date-and-time-formats
      // For time zones, see:
      // https://developers.google.com/adwords/api/docs/appendix/codes-formats#timezone-ids

      //  The conversion time should be after the call start time.
      string conversionTime = "INSERT_CONVERSION_TIME_HERE";
      string callStartTime = "INSERT_CALL_START_TIME_HERE";

      string callerId = "INSERT_CALLER_ID_HERE";
      double conversionValue = double.Parse("INSERT_CONVERSION_VALUE_HERE");

      UploadOfflineCallConversions codeExample = new UploadOfflineCallConversions();
      Console.WriteLine(codeExample.Description);
      try {
        codeExample.Run(new AdWordsUser(), conversionName, callStartTime, callerId,
            conversionTime, conversionValue);
      } catch (Exception e) {
        Console.WriteLine("An exception occurred while running this code example. {0}",
            ExampleUtilities.FormatException(e));
      }
    }

    /// <summary>
    /// Returns a description about the code example.
    /// </summary>
    public override string Description {
      get {
        return "This code example imports offline call conversion values for calls related " +
            "to the ads in your account.";
      }
    }

    /// <summary>
    /// Runs the code example.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="conversionName">The name of the call conversion to be updated.</param>
    /// <param name="callStartTime">The call start time.</param>
    /// <param name="conversionValue">The conversion value to be uploaded.</param>
    /// <param name="callerId">The caller ID to be uploaded.</param>
    /// <param name="conversionTime">The conversion time, in yyyymmdd hhmmss
    /// format.</param>
    public void Run(AdWordsUser user, String conversionName, String callStartTime, String callerId,
        String conversionTime, double conversionValue) {
      // Get the OfflineConversionFeedService.
      OfflineCallConversionFeedService offlineCallConversionFeedService =
          (OfflineCallConversionFeedService) user.GetService(
              AdWordsService.v201705.OfflineCallConversionFeedService);

      // Associate offline call conversions with the existing named conversion tracker. If this
      // tracker was newly created, it may be a few hours before it can accept conversions.
      OfflineCallConversionFeed feed = new OfflineCallConversionFeed();
      feed.callerId = callerId;
      feed.callStartTime = callStartTime;
      feed.conversionName = conversionName;
      feed.conversionTime = conversionTime;
      feed.conversionValue = conversionValue;

      OfflineCallConversionFeedOperation offlineCallConversionOperation =
          new OfflineCallConversionFeedOperation();
      offlineCallConversionOperation.@operator = Operator.ADD;
      offlineCallConversionOperation.operand = feed;

      try {
        // This example uploads only one call conversion, but you can upload
        // multiple call conversions by passing additional operations.
        OfflineCallConversionFeedReturnValue offlineCallConversionReturnValue =
            offlineCallConversionFeedService.mutate(
                new OfflineCallConversionFeedOperation[] { offlineCallConversionOperation });

        // Display results.
        foreach (OfflineCallConversionFeed feedResult in offlineCallConversionReturnValue.value) {
          Console.WriteLine("Uploaded offline call conversion value of {0} for caller ID '{1}'.",
              feedResult.conversionValue, feedResult.callerId);
        }
      } catch (Exception e) {
        throw new System.ApplicationException("Failed to upload offline call conversions.", e);
      }
    }
  }
}

Send feedback about...

AdWords API
AdWords API
Need help? Visit our support page.