NAME

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

VERSION

This documentation refers to Google::Adwords::AdService version 0.3

SYNOPSIS

        use Google::Adwords::AdService;
        use Google::Adwords::Ad;
        use Google::Adwords::Image;

        use File::Slurp;

        my $adgroup_id = 20048;

        # Create Text Ad
        my $ad1 = Google::Adwords::Ad->new
            ->adType('TextAd')
            ->headline('The World is Flat')
            ->description1('Yes')
            ->description2('It is')
            ->adGroupId($adgroup_id)
            ->destinationUrl('http://aarohan.biz')
            ->displayUrl('aarohan.biz')

        # Create an Image Ad
        my $ad2 = Google::Adwords::Ad->new
            ->adType('ImageAd')
            ->adGroupId($adgroup_id)
            ->destinationUrl('http://aarohan.biz')
            ->displayUrl('aarohan.biz');

        # The image stuff
        my $image_data = read_file('picture.jpg');
        my $image = Google::Adwords::Image->new;
        $image->name('picture.jpg');
        $image->data($image_data);

        # Associate the image with the Image Ad
        $ad2->image($image);

        # Create the AdService
        my $service = Google::Adwords::AdService->new();

        # login details
        $service->email('email@domain.com')
                ->password('password')
                ->developerToken($developer_token)
                ->applicationToken($app_token);

        # if you use a MCC
        #$service->clientEmail('clientemail@domain.com');
        # or 
        #$service->clientCustomerId('xxx-xxx-xxxx');

        # Add the two ads
        my @added_ads = $service->addAds($ad1, $ad2);
  

DESCRIPTION

This module provides an interface to the Google Adwords AdService API calls.

METHODS

addAds()

Description

    Make a batch of new Ads. The adGroupId field of the Ad indicates which AdGroup to add the Ad to. The adGroupId field is required, and the indicated AdGroup must exist already.

Usage

    my @ads = $service->addAds($ad1, $ad2);

Parameters

    A list of Google::Adwords::Ad objects to be added.

Returns

    A list of Google::Adwords::Ad objects just created with their IDs filled in.

findBusinesses()

Description

    Searches for businesses with similar attributes. This call is similar to querying Google Local Search. All parameters are required.

Usage

    my @businesses = $service->findBusinesses({
        name    => 'business name',
        address => 'address of business',
        countryCode => 'IN',
    });

Parameters

A hashref with following keys :

  • name => Name of the business

  • address => Location of the business

  • countryCode => Two letter country code of the business address.

Returns

    A list of matching businesses, each as a Google::Adwords::Business object

getActiveAds()

Description

    Return all active Ads associated with the list of AdGroup ids specified.

Usage

    my @ads = $obj->getActiveAds($adgroupid1, $adgroupid2);

Parameters

    List of adgroupids from which we want the active Ads

Returns

    A list of Google::Adwords::Ad objects

getAd()

Description

    Return information about one Ad.

Usage

    my $ad = $service->getAd($adgroup_id, $ad_id);

Parameters

1) $adgroup_id => The ID of the AdGroup owning the Ad
2) $ad_id => The ID of the Ad

Returns

    The requested Ad as a Google::Adwords::Ad object.

getAdStats()

Description

    Get statistics for a list of ads in an ad group.

Usage

    my @ad_stats = $service->getAdStats({
        adGroupId   => 1234,
        adIds       => [ 3982, 2787, 17872 ],
        startDay    => $startDay,
        endDay      => $endDay,
        inPST       => 1,
    });

Parameters

Takes a hashref with following keys,

    * adGroupId => The ad group that contains the Ads to be queried

    * adIds => array reference of Ad IDs

    * startDay => The starting day of the period for which statistics are to be collected in format YYYY-MM-DD

    * endDay => The ending day of the period for which statistics are to be collected in format YYYY-MM-DD

    * inPST => Set to 1 to get stats in America/Los_Angeles timezone (Google headquarters) regardless of the parent account's localtimezone.

Returns

    A list of Google::Adwords::StatsRecord objects

getAllAds()

Description

    Return all Ads (enabled, disabled, or paused) associated with the list of AdGroup ids specified.

Usage

    my @ads = $service->getAllAds($adgroup_id1, $adgroup_id2);

Parameters

    A list of AdGroup IDs that own the Ads

Returns

    A list of Google::Adwords::Ad objects

getMyBusinesses()

Description

    Returns the list of businesses registered to the user in the Local Business Center. The user is determined by the clientEmail header if it is specified. Otherwise, the email header is used instead.

Usage

    my @businesses = $self->getMyBusinesses();

Parameters

    NONE

Returns

    A list of Google::Adwords::Business objects

updateAds()

Description

    Update a batch of ads. Use the id field of the ad to indicate which ad to update. Currently only the status field is updateable, all other fields will be ignored.

Usage

    $ret = $obj->updateAds($ad1, $ad2);

Parameters

    A List of Google::Adwords::Ad objects to be updated

Returns

    1 on success

SEE ALSO

AUTHORS

Rohan Almeida <rohan@almeida.in>

Mathieu Jondet <mathieu@eulerian.com>

LICENSE 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.