In addition to the traditional feed-backed extensions, you can also create asset-backed ad extensions in your Google Ads account. Currently, lead form extensions are the only type of asset-backed extension, but there will be more asset-backed extension types in the future.
Creating an extension
There are two steps to creating an asset-backed extension.
- Create a new asset.
- Associate the asset with a campaign.
We examine each of these steps by creating a Lead form extension.
Create an asset
You can create a lead form asset by creating an Asset
object and populating the
lead_form_asset
field. Call the
AssetService::MutateAssets()
method to execute an AssetOperation
with the
create
field set to the new asset
object.
private string CreateLeadFormAsset(GoogleAdsClient client, long customerId)
{
AssetServiceClient assetService = client.GetService(Services.V6.AssetService);
// Creates the lead form asset.
Asset leadFormAsset = new Asset()
{
Name = $"Interplanetary Cruise #{ExampleUtilities.GetRandomString()} Lead Form",
LeadFormAsset = new LeadFormAsset()
{
// Specify the details of the extension that the users will see.
CallToActionType = LeadFormCallToActionType.BookNow,
CallToActionDescription = "Latest trip to Jupiter!",
// Define the form details.
BusinessName = "Interplanetary Cruise",
Headline = "Trip to Jupiter",
Description = "Our latest trip to Jupiter is now open for booking.",
PrivacyPolicyUrl = "http://example.com/privacy",
// Define the fields to be displayed to the user.
Fields = {
new LeadFormField()
{
InputType = LeadFormFieldUserInputType.FullName,
},
new LeadFormField()
{
InputType = LeadFormFieldUserInputType.Email,
},
new LeadFormField()
{
InputType = LeadFormFieldUserInputType.PhoneNumber,
},
new LeadFormField()
{
InputType = LeadFormFieldUserInputType.PreferredContactTime,
SingleChoiceAnswers = new LeadFormSingleChoiceAnswers()
{
Answers = { "Before 9 AM", "Any time", "After 5 PM" }
}
},
new LeadFormField()
{
InputType = LeadFormFieldUserInputType.TravelBudget,
},
},
// Optional: You can also specify a background image asset.
// To upload an asset, see Misc/UploadImageAsset.cs.
// BackgroundImageAsset = "INSERT_IMAGE_ASSET_HERE",
// Optional: Define the response page after the user signs up on the form.
PostSubmitHeadline = "Thanks for signing up!",
PostSubmitDescription = "We will reach out to you shortly. Visit our website " +
"to see past trip details.",
PostSubmitCallToActionType = LeadFormPostSubmitCallToActionType.VisitSite,
// Optional: Display a custom disclosure that displays along with the Google
// disclaimer on the form.
CustomDisclosure = "Trip may get cancelled due to meteor shower.",
// Optional: Define a delivery method for the form response. See
// https://developers.google.com/google-ads/webhook/docs/overview for more
// details on how to define a webhook.
DeliveryMethods =
{
new LeadFormDeliveryMethod()
{
Webhook = new WebhookDelivery()
{
AdvertiserWebhookUrl = "http://example.com/webhook",
GoogleSecret = "interplanetary google secret",
PayloadSchemaVersion = 3L
}
}
},
},
FinalUrls = { "http://example.com/jupiter" }
};
// Creates the operation.
AssetOperation operation = new AssetOperation()
{
Create = leadFormAsset,
};
// Makes the API call.
MutateAssetsResponse response = assetService.MutateAssets(customerId.ToString(),
new[] { operation });
string leadFormAssetResourceName = response.Results[0].ResourceName;
// Displays the result.
Console.WriteLine($"Asset with resource name = '{leadFormAssetResourceName}' " +
"was created.");
return leadFormAssetResourceName;
}
Associate the asset with a campaign
Next, associate the asset with a campaign by creating a
CampaignAsset
object. Set the
field_type
field to
LEAD_FORM
. Call
the
CampaignAssetService::MutateCampaignAssets()
method to execute a
CampaignAssetOperation
with the
create
field set to the new
CampaignAsset
object.
private void CreateLeadFormExtension(GoogleAdsClient client, long customerId,
long campaignId, string leadFormAssetResourceName)
{
CampaignAssetServiceClient campaignAssetService = client.GetService(
Services.V6.CampaignAssetService);
// Creates the campaign asset for the lead form.
CampaignAsset campaignAsset = new CampaignAsset()
{
Asset = leadFormAssetResourceName,
FieldType = AssetFieldTypeEnum.Types.AssetFieldType.LeadForm,
Campaign = ResourceNames.Campaign(customerId, campaignId),
};
CampaignAssetOperation operation = new CampaignAssetOperation()
{
Create = campaignAsset
};
MutateCampaignAssetsResponse response = campaignAssetService.MutateCampaignAssets(
customerId.ToString(), new[] { operation });
foreach (MutateCampaignAssetResult result in response.Results)
{
Console.WriteLine("Created campaign asset with resource name =" +
$" '{result.ResourceName}' for campaign ID {campaignId}.");
}
}
Updating the extension
To update the underlying extension properties,
update
the Asset
using the
MutateAssets
method from AssetService
. To remove the extension from a
campaign, remove
the CampaignAsset
.