NAME

Google::Adwords::CreativeService - Interact with the Google Adwords CreativeService API calls

VERSION

This documentation refers to Google::Adwords::CreativeService version 0.2

SYNOPSIS

  use Google::Adwords::CreativeService;
  use Google::Adwords::Image;
  use Google::Adwords::Creative;

  use File::Slurp;

  # create the CreativeService object
  my $creative_service = Google::Adwords::CreativeService->new();

  # need to login to the Adwords service
  $creative_service->email($email_address)
                   ->password($password)
                   ->developerToken($developer_token)
                   ->applicationToken($app_token);

  # if you have a MCC
  $creative_service->clientEmail($client_email);

  my $adgroupid	= 123456789;

  # get all the creatives for an adgroup
  my @getallcreatives	= $creative_service->getAllCreatives($adgroupid);
  for ( @getallcreatives ) {
      print "Creative name : " . $_->name . " , Id : " . $_->id . "\n";
  }

  # get a specific creative from an AdGroup
  my $creativeid	= 987654321;

  my $getcreative	= $creative_service->getCreative($adgroupid, $creativeid);
  print "Get creative: " . $getcreative->name . ", Id : " . $getcreative->id . "\n";

  # activate a creative
  my $ret = $creative_service->activateCreative($adgroupid, $creativeid);

  # activate a list of creative
  my @activate_list = (
      {
          adGroupId => 1234,
          creativeId => 12,
      },
      {
          adGroupId => 5789,
          creativeId => 209,
      },
  );
  my $ret = $creative_service->activateCreativeList(@activate_list);

  # delete a creative
  my $ret	= $creative_service->deleteCreative($adgroupid, $creativeid);
  
  # add a creative
  my $creative_text = Google::Adwords::Creative->new
          ->adGroupId($adgroupid)
          ->destinationUrl('http://www.example.com')
          ->displayUrl('http://www.example.com')
          ->headline('API : creative')
          ->description1('desc1 added via API')
          ->description2('desc2 added via API');

  my $addcreative	= $creative_service->addCreative($creative_text);
  print "Added Creative ID: " . $addcreative->id . "\n";

  # add a image creative
  my $data_blurb = read_file('image.gif');

  my $image	= Google::Adwords::Image->new
          ->name('Image #1')
          ->data($data_blurb)
          ->type('image');
  
  my $creative_image = Google::Adwords::Creative->new
          ->adGroupId($adgroupid)
          ->destinationUrl('http://www.example.com')
          ->displayUrl('http://www.example.com')
          ->image( $image );
  
  my $addcreative	= $creative_service->addCreative($creative_image);
  print "Added Creative ID: " . $addcreative->id . "\n";
  print "Image Height: " . $addcreative->image->height . "\n";

DESCRIPTION

This module provides an interface to the Google Adwords CreativeService API calls. Please read Google::Adwords::Creative on how to setup and receive information about your creatives.

METHODS

activateCreative()

Description

Mark a Creative as active. Active Creatives will be served.

Creatives are active by default when they are first created, but it is possible to create them in the deleted (inactive) state, or to inactivate them by marking them as deleted. A "deleted" creative can be undeleted and made active again by the activateCreative operation.

To undo this operation, call deleteCreative.

Usage

my $ret = $obj->activateCreative($adGroupId, $creativeId);

Parameters

1) $adGroupId : id of the Adgroup
2) $creativeId : id of the Creative

Returns

1 on success

activateCreativeList()

Description

Mark a list of Creatives as active. Each pair of (adGroupId, creativeId) parameters specifies one Creative to activate. See activateCreative.

To undo this operation, call deleteCreativeList.

Usage

my @pairs = (
    {
        adGroupId => 1244,
        creativeId => 15,
    },
    {
        adGroupId => 4561,
        creativeId => 29,
    },
);
my $ret = $obj->activateCreativeList(@pairs);

Parameters

A list of hashrefs with keys (each forming a pair) :

  • adGroupId : id of the Adgroup

  • creativeId : id of the Creative

Returns

1 on success

addCreative()

Description

Make a new Creative. The Creative can either be a text Creative or an image.

Usage

my $creative_response = $obj->addCreative($creative);

Parameters

$creative => A Google::Adwords::Creative object

Returns

$creative_response => The newly added creative as a Google::Adwords::Creative object

addCreativeList()

Description

Make a batch of new Creatives.

Usage

my @creatives = $obj->addCreativeList($creative1, $creative2);

Parameters

A list of Google::Adwords::Creative objects

Returns

The list of created creatives, each as a Google::Adwords::Creative object

deleteCreative()

Description

Mark a Creative as deleted. Deleted Creatives will not be served. If the Creative is already deleted, this does nothing.

Usage

my $ret = $obj->deleteCreative($adGroupId, $creativeId);

Parameters

  • 1) $adGroupId : the id of the adgroup =item * 2) $creativeId : the id of the creative

Returns

1 on success

deleteCreativeList()

Description

Mark a list of Creatives as deleted. Each pair of (adGroupId, creativeId) parameters specifies one Creative to delete. To undo this operation, call activateCreativeList.

Usage

my @pairs = (
    {
        adGroupId => 1244,
        creativeId => 15,
    },
    {
        adGroupId => 4561,
        creativeId => 29,
    },
);
my $ret = $obj->deleteCreativeList(@pairs);

Parameters

A list of hashrefs (each representing a pair) with keys :

  • adGroupId : id of the Adgroup

  • creativeId : id of the Creative

Returns

1 on success

getActiveCreatives()

Description

Return all active Creatives associated with an AdGroup.

Usage

my @creatives = $obj->getActiveCreatives($adgroupid);

Parameters

1) $adgroupid : the id of the AdGroup.

Returns

A list of Google::Adwords::Creative objects.

getAllCreatives()

Description

Return all Creatives (active and deleted) associated with an AdGroup

Usage

my @creatives = $obj->getAllCreatives($adgroupid);

Parameters

1) $adgroupid : the id of the AdGroup.

Returns

A list of Google::Adwords::Creative objects.

getCreative()

Description

Return information about one Creative.

Usage

my $creative = $obj->getCreative($adgroupid, $creativeid);

Parameters

1) $adgroupid : the id of the AdGroup
2) $creativeid : the id of the Creative.

Returns

$creative => The creative info as a Google::Adwords::Creative object

SEE ALSO

AUTHORS

Rohan Almeida <rohan@almeida.in>

Mathieu Jondet <mathieu@eulerian.com>

LICENCE AND COPYRIGHT

Copyright (c) 2006 Rohan Almeida <rohan@almeida.in>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.