Skip to content

Help with AMP setup -  #112

Description

@tinchisla

Hi there,
I've use this tool for Standard creatives and it worked perfect. Now I'm trying to do the same for AMP.

In create_creatives.py, I've added just two lines in:

def create_creative_config(name, advertiser_id, video_ad_type, redirect_url):

snippet_file_path = os.path.join(os.path.dirname(__file__), "creative_snippet.html")
with open(snippet_file_path, "r") as snippet_file:
    snippet = snippet_file.read()

# https://developers.google.com/doubleclick-publishers/docs/reference/v201802/CreativeService.Creative
config = {
    "xsi_type": "ThirdPartyCreative",
    "name": name,
    "advertiserId": advertiser_id,
    "size": {"width": "1", "height": "1"},
    "snippet": snippet,
    "isSafeFrameCompatible": False,
    # la siguiente línea solo es en caso de AMP - comentar en caso de un creativo común
    "ampRedirectUrl": "https://acceleratedmobilepageurl.googleapis.com/v1/ampUrls:batchGet", # FIRST LINE
}

if video_ad_type:
    config["xsi_type"] = "VastRedirectCreative"
    config["duration"] = 1000
    config["size"] = {"width": "640", "height": "480"}
    config["vastXmlUrl"] = redirect_url
else:
    config["xsi_type"] = "ThirdPartyCreative"
    config["snippet"] = snippet
    config["isSafeFrameCompatible"] = False
    config["size"] = {"width": "1", "height": "1"}
      # la siguiente línea solo es en caso de AMP - comentar en caso de un creativo común

    config["ampRedirectUrl"] = "https://acceleratedmobilepageurl.googleapis.com/v1/ampUrls:batchGet" # SECOND LINE

return config

But, I'm getting this error:

k: self._PackArgumentsHelper(elem_arguments[k], v, set_type_attrs)

KeyError: 'ampRedirectUrl'

Definetely, I need help to config this for AMP. I really don't know what to do.
I could see that, I have to change the creative code type in GAM from Standard to Standard & AMP. I don't know how to do that with this tool. Is it possible?
Should I change anything else?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions