gads

package module
v0.0.0-...-e1ffc06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2015 License: MIT Imports: 12 Imported by: 0

README

gads

Package gads provides a wrapper for the Google Adwords SOAP API.

installation

go get github.com/emiddleton/gads

setup

In order to access the API you will need to sign up for an MMC account[1], get a developer token[2] and setup authentication[3]. There is a tool in the setup_oauth2 directory that will help you setup a configuration file.

  1. http://www.google.com/adwords/myclientcenter/
  2. https://developers.google.com/adwords/api/docs/signingup
  3. https://developers.google.com/adwords/api/docs/guides/authentication

usage

The package is comprised of services used to manipulate various adwords structures. To access a service you need to create an gads.Auth and parse it to the service initializer, then can call the service methods on the service object.

     authConf, err := NewCredentials(context.TODO())
     campaignService := gads.NewCampaignService(&authConf.Auth)

     campaigns, totalCount, err := cs.Get(
       gads.Selector{
         Fields: []string{
           "Id",
           "Name",
           "Status",
         },
       },
     )

Note: This package is a work-in-progress, and may occasionally make backwards-incompatible changes.

See godoc for further documentation and examples.

about

Gads is developed by Edward Middleton

Documentation

Overview

Package gads provides a wrapper for the Google Adwords SOAP API. In order to access the API you will need to sign up for an MMC account[1], get a developer token[2], setup authentication[3]. The is a tool in the setup_oauth2 directory that will setup a configuration file.

The package is comprised of services used to manipulate various adwords structures. To access a service you need to create an gads.Auth and parse it to the service initializer, then can call the service methods on the service object.

authConf, err := NewCredentials(context.TODO())
campaignService := gads.NewCampaignService(&authConf.Auth)

campaigns, totalCount, err := cs.Get(
  gads.Selector{
    Fields: []string{
      "Id",
      "Name",
      "Status",
    },
  },
)

1. http://www.google.com/adwords/myclientcenter/

2. https://developers.google.com/adwords/api/docs/signingup

3. https://developers.google.com/adwords/api/docs/guides/authentication

Index

Examples

Constants

View Source
const (

	// used for developpement, if true all unknown field will raise an error
	StrictMode = false
)

Variables

View Source
var (
	ERROR_NOT_YET_IMPLEMENTED = fmt.Errorf("Not yet implemented")
)

exceptions

Functions

This section is empty.

Types

type Ad interface {
	GetID() int64
	GetURL() string
	GetTrackingURLTemplate() *string
	GetFinalURLs() []string

	CloneForTemplate([]string, *string) Ad
}

Ad is the common interface for accessing properties shared by all child types of ads

type AdError

type AdError struct {
	FieldPath   string `xml:"fieldPath"`
	Trigger     string `xml:"trigger"`
	ErrorString string `xml:"errorString"`
	Reason      string `xml:"reason"`
}

type AdGroup

type AdGroup struct {
	Id                           int64                          `xml:"id,omitempty"`
	CampaignId                   int64                          `xml:"campaignId,omitempty"`
	CampaignName                 string                         `xml:"campaignName,omitempty"`
	Name                         string                         `xml:"name,omitempty"`
	Status                       string                         `xml:"status,omitempty"`
	Settings                     []AdSetting                    `xml:"settings,omitempty"`
	TrackingUrlTemplate          *string                        `xml:"trackingUrlTemplate,omitempty"`
	BiddingStrategyConfiguration []BiddingStrategyConfiguration `xml:"biddingStrategyConfiguration,omitempty"`
	ContentBidCriterionTypeGroup *string                        `xml:"contentBidCriterionTypeGroup,omitempty"`
}

type AdGroupAd

type AdGroupAd struct {
	AdGroupId            int64    `xml:"adGroupId"`
	Ad                   Ad       `xml:"ad"`
	Status               string   `xml:"status,omitempty"`
	ApprovalStatus       string   `xml:"approvalStatus,omitempty"`
	DisapprovalReasons   []string `xml:"disapprovalReasons,omitempty"`
	TrademarkDisapproved bool     `xml:"trademarkDisapproved,omitempty"`
	Labels               []Label  `xml:"labels,omitempty"`
}

func NewAdGroupTextAd

func NewAdGroupTextAd(
	adGroupId int64,
	URL string,
	displayURL string,
	headline string,
	description1 string,
	description2 string,
	status string,
) AdGroupAd

type AdGroupAdLabel

type AdGroupAdLabel struct {
	AdGroupAdId int64 `xml:"adGroupAdId"`
	LabelId     int64 `xml:"labelId"`
}

type AdGroupAdLabelOperations

type AdGroupAdLabelOperations map[string][]AdGroupAdLabel

type AdGroupAdOperations

type AdGroupAdOperations map[string]AdGroupAds

type AdGroupAdService

type AdGroupAdService struct {
	Auth
}

func NewAdGroupAdService

func NewAdGroupAdService(auth *Auth) *AdGroupAdService

func (AdGroupAdService) Get

func (s AdGroupAdService) Get(selector Selector) (adGroupAds AdGroupAds, totalCount int64, err error)

Get returns an array of ad's and the total number of ad's matching the selector.

Example

ads, totalCount, err := adGroupAdService.Get(
  gads.Selector{
    Fields: []string{
      "AdGroupId",
      "Status",
      "AdGroupCreativeApprovalStatus",
      "AdGroupAdDisapprovalReasons",
      "AdGroupAdTrademarkDisapproved",
    },
    Predicates: []gads.Predicate{
      {"AdGroupId", "EQUALS", []string{adGroupId}},
    },
  },
)

Selectable fields are

"AdGroupId", "Id", "Url", "DisplayUrl", "CreativeFinalUrls", "CreativeFinalMobileUrls",
"CreativeFinalAppUrls", "CreativeTrackingUrlTemplate", "CreativeUrlCustomParameters",
"DevicePreference", "Status", "AdGroupCreativeApprovalStatus", "AdGroupAdDisapprovalReasons"
"AdGroupAdTrademarkDisapproved", "Labels"

TextAd
  "Headline", "Description1", "Description2"

ImageAd
  "ImageCreativeName"

filterable fields are

"AdGroupId", "Id", "Url", "DisplayUrl", "CreativeFinalUrls", "CreativeFinalMobileUrls",
"CreativeFinalAppUrls", "CreativeTrackingUrlTemplate", "CreativeUrlCustomParameters",
"DevicePreference", "Status", "AdGroupCreativeApprovalStatus", "AdGroupAdDisapprovalReasons"
"Labels"

TextAd specific fields
  "Headline", "Description1", "Description2"

ImageAd specific fields
  "ImageCreativeName"

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupAdService#get
Example
authConf, _ := NewCredentials(context.TODO())
agas := NewAdGroupAdService(&authConf.Auth)

// This example illustrates how to retrieve all text ads for an ad group.
adGroupId := "1"
var pageSize int64 = 500
var offset int64 = 0
paging := Paging{
	Offset: offset,
	Limit:  pageSize,
}
var totalCount int64 = 0
for {
	adGroupAds, totalCount, err := agas.Get(
		Selector{
			Fields: []string{
				"Id",
				"Status",
				"AdType",
			},
			Ordering: []OrderBy{
				{"Id", "ASCENDING"},
			},
			Predicates: []Predicate{
				{"AdGroupId", "IN", []string{adGroupId}},
				{"Status", "IN", []string{"ENABLED", "PAUSED", "DISABLED"}},
				{"AdType", "EQUALS", []string{"TEXT_AD"}},
			},
			Paging: &paging,
		},
	)
	if err != nil {
		fmt.Printf("Error occured finding ad group ad")
	}
	for _, aga := range adGroupAds {
		ta := aga.(TextAd)
		fmt.Printf("Ad ID is %d, type is 'TextAd' and status is '%s'", ta.Id, ta.Status)
	}
	// Increment values to request the next page.
	offset += pageSize
	paging.Offset = offset
	if totalCount < offset {
		break
	}
}
fmt.Printf("\tAd group ID %d has %d ad(s).", totalCount)
Output:

func (*AdGroupAdService) Mutate

func (s *AdGroupAdService) Mutate(adGroupAdOperations AdGroupAdOperations) (adGroupAds AdGroupAds, err error)

Mutate allows you to add, modify and remove ads, returning the modified ads.

Example

ads, err := adGroupAdService.Mutate(
  gads.AdGroupAdOperations{
    "ADD": {
      gads.NewAdGroupTextAd(
        adGroup.Id,
        "https://classdo.com/en",
        "classdo.com",
        "test headline",
        "test line one",
        "test line two",
        "PAUSED",
      ),
    },
    "SET": {
      modifiedAd,
    },
    "REMOVE": {
      adNeedingRemoval,
    },
  },
)

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupAdService#mutate
Example
authConf, err := NewCredentials(context.TODO())
agas := NewAdGroupAdService(&authConf.Auth)

// This example illustrates how to add text ads to a given ad group.
var adGroupId int64 = 1

adGroupAds, err := agas.Mutate(
	AdGroupAdOperations{
		"ADD": {
			NewTextAd(
				adGroupId,
				"http://www.example.com",
				"example.com",
				"Luxury Cruise to Mars",
				"Visit the Red Planet in style.",
				"Low-gravity fun for everyone!",
				"ACTIVE",
			),
			NewTextAd(
				adGroupId,
				"http://www.example.com",
				"www.example.com",
				"Luxury Cruise to Mars",
				"Enjoy your stay at Red Planet.",
				"Buy your tickets now!",
				"ACTIVE",
			),
		},
	},
)
if err != nil {
	fmt.Printf("No ads were added.")
} else {
	fmt.Printf("Added %d ad(s) to ad group ID %d:", len(adGroupAds), adGroupId)
	for _, ada := range adGroupAds {
		ta := ada.(TextAd)
		fmt.Printf("\tAd ID %d, type 'TextAd' and status '%s'", ta.Id, ta.Status)
	}
}

// This example illustrates how to update an ad, setting its status to 'PAUSED'.
textAdId := adGroupAds[0].(TextAd).Id
adGroupAds, err = agas.Mutate(
	AdGroupAdOperations{
		"SET": {
			TextAd{
				AdGroupId: adGroupId,
				Id:        textAdId,
				Status:    "PAUSED",
			},
		},
	},
)
if err != nil {
	fmt.Printf("No ads were updated.")
} else {
	textAd := adGroupAds[0].(TextAd)
	fmt.Printf("Ad ID %d was successfully updated, status set to '%s'.", textAd.Id, textAd.Status)
}

// This example removes an ad using the 'REMOVE' operator.
adGroupAds, err = agas.Mutate(
	AdGroupAdOperations{
		"SET": {
			TextAd{
				AdGroupId: adGroupId,
				Id:        textAdId,
				Status:    "REMOVE",
			},
		},
	},
)
if err != nil {
	fmt.Printf("No ads were removed.")
} else {
	textAd := adGroupAds[0].(TextAd)
	fmt.Printf("Ad ID %d was successfully removed.", textAd.Id)
}
Output:

func (*AdGroupAdService) MutateLabel

func (s *AdGroupAdService) MutateLabel(adGroupAdLabelOperations AdGroupAdLabelOperations) (adGroupAdLabels []AdGroupAdLabel, err error)

MutateLabel allows you to add and removes labels from ads.

Example

ads, err := adGroupAdService.MutateLabel(
  gads.AdGroupAdLabelOperations{
    "ADD": {
      gads.AdGroupAdLabel{AdGroupAdId: 3200, LabelId: 5353},
      gads.AdGroupAdLabel{AdGroupAdId: 4320, LabelId: 5643},
    },
    "REMOVE": {
      gads.AdGroupAdLabel{AdGroupAdId: 3653, LabelId: 5653},
    },
  }

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupAdService#mutateLabel

func (*AdGroupAdService) Query

func (s *AdGroupAdService) Query(query string) (adGroupAds AdGroupAds, totalCount int64, err error)

Query is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupAdService#query

func (*AdGroupAdService) UpgradeUrl

func (s *AdGroupAdService) UpgradeUrl(adURLUpgrades []AdURLUpgrade) (ads []Ad, err error)

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupAdService#upgradeUrl

type AdGroupAds

type AdGroupAds []AdGroupAd

func (AdGroupAds) GetAds

func (agads AdGroupAds) GetAds() (ads []Ad)

func (*AdGroupAds) UnmarshalXML

func (agas *AdGroupAds) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error

type AdGroupBidModifierService

type AdGroupBidModifierService struct {
	Auth
}

func NewAdGroupBidModifierService

func NewAdGroupBidModifierService(auth *Auth) *AdGroupBidModifierService

type AdGroupCriterionLabel

type AdGroupCriterionLabel struct {
	AdGroupCriterionId int64 `xml:"adGroupCriterionId"`
	LabelId            int64 `xml:"labelId"`
}

type AdGroupCriterionLabelOperations

type AdGroupCriterionLabelOperations map[string][]AdGroupCriterionLabel

type AdGroupCriterionOperations

type AdGroupCriterionOperations map[string]AdGroupCriterions

type AdGroupCriterionService

type AdGroupCriterionService struct {
	Auth
}

func NewAdGroupCriterionService

func NewAdGroupCriterionService(auth *Auth) *AdGroupCriterionService

func (AdGroupCriterionService) Get

func (s AdGroupCriterionService) Get(selector Selector) (adGroupCriterions AdGroupCriterions, totalCount int64, err error)

Get returns an array of AdGroupCriterion's and the total number of AdGroupCriterion's matching the selector.

Example

adGroupCriterions, totalCount, err := adGroupCriterionService.Get(
  Selector{
    Fields: []string{"Id","KeywordText","KeywordMatchType"},
    Predicates: []Predicate{
      {"AdGroupId", "EQUALS", []string{"432434"}},
    },
  },
)

Selectable fields are

"AdGroupId", "CriterionUse", "Id", "CriteriaType", "Labels"

AgeRange
  "AgeRangeType",

AppPaymentModel
  "AppPaymentModelType",

CriterionUserInterest
  "UserInterestId", "UserInterestName",

CriterionUserList
  "UserListId", "UserListName", "UserListMembershipStatus"

Gender
  "GenderType"

Keyword
  "KeywordText", "KeywordMatchType"

MobileAppCategory
  "MobileAppCategoryId"

MobileApplication
  "DisplayName"

Placement
  "PlacementUrl"

Product
  "Text"

ProductPartition
  "PartitionType", "ParentCriterionId", "CaseValue"

Vertical
  "VerticalId", "VerticalParentId", "Path"

Webpage
  "Parameter", "CriteriaCoverage", "CriteriaSamples"

filterable fields are

"AdGroupId", "CriterionUse", "Id", "CriteriaType", "Labels"

CriterionUserList
  "UserListMembershipStatus"

Keyword
  "KeywordText", "KeywordMatchType"

MobileApplication
  "DisplayName"

Placement
  "PlacementUrl"

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupCriterionService#get
Example
authConf, _ := NewCredentials(context.TODO())
agcs := NewAdGroupCriterionService(&authConf.Auth)

// This example illustrates how to retrieve all keywords for an ad group.
adGroupId := "1"
var pageSize int64 = 500
var offset int64 = 0
paging := Paging{
	Offset: offset,
	Limit:  pageSize,
}
for {
	adGroupCriterions, totalCount, err := agcs.Get(
		Selector{
			Fields: []string{
				"Id",
				"CriteriaType",
				"KeywordText",
			},
			Ordering: []OrderBy{
				{"Id", "ASCENDING"},
			},
			Predicates: []Predicate{
				{"AdGroupId", "EQUALS", []string{adGroupId}},
				{"CriteriaType", "EQUALS", []string{"KEYWORD"}},
			},
			Paging: &paging,
		},
	)
	if err != nil {
		fmt.Printf("Error occured finding ad group criterion")
	}
	for _, agc := range adGroupCriterions {
		kc := agc.(BiddableAdGroupCriterion).Criterion.(KeywordCriterion)
		fmt.Printf("Keyword ID %d, type '%s' and text '%s'", kc.Id, kc.MatchType, kc.Text)
	}
	// Increment values to request the next page.
	offset += pageSize
	paging.Offset = offset
	if totalCount < offset {
		fmt.Printf("\tAd group ID %d has %d keyword(s).", totalCount)
		break
	}
}
Output:

func (*AdGroupCriterionService) Mutate

func (s *AdGroupCriterionService) Mutate(adGroupCriterionOperations AdGroupCriterionOperations) (adGroupCriterions AdGroupCriterions, err error)

Mutate allows you to add, modify and remove ad group criterion, returning the modified ad group criterion.

Example

ads, err := adGroupService.Mutate(
  gads.AdGroupCriterionOperations{
    "ADD": {
      BiddableAdGroupCriterion{
        AdGroupId:  adGroupId,
        Criterion:  gads.KeywordCriterion{Text: "test1", MatchType: "EXACT"},
        UserStatus: "PAUSED",
      },
      NegativeAdGroupCriterion{
        AdGroupId: adGroupId,
        Criterion: gads.KeywordCriterion{Text: "test4", MatchType: "BROAD"},
      },
    },
    "SET": {
      modifiedAdGroupCriterion,
    },
    "REMOVE": {
      adGroupCriterionNeedingRemoval,
    },
  },
)

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupCriterionService#mutate
Example
authConf, err := NewCredentials(context.TODO())
agcs := NewAdGroupCriterionService(&authConf.Auth)

var adGroupId int64 = 1

// This example illustrates how to add multiple keywords to a given ad group.
adGroupCriterions, err := agcs.Mutate(
	AdGroupCriterionOperations{
		"ADD": {
			BiddableAdGroupCriterion{
				AdGroupId: adGroupId,
				Criterion: KeywordCriterion{
					Text:      "mars cruise",
					MatchType: "BROAD",
				},
				UserStatus:     "PAUSED",
				DestinationUrl: "http://example.com/mars",
			},
			BiddableAdGroupCriterion{
				AdGroupId: adGroupId,
				Criterion: KeywordCriterion{
					Text:      "space hotel",
					MatchType: "BROAD",
				},
			},
		},
	},
)
if err != nil {
	fmt.Printf("No keywords were added.")
} else {
	fmt.Printf("Added %d keywords to ad group ID %d:", len(adGroupCriterions), adGroupId)
	for _, agc := range adGroupCriterions {
		k := agc.(BiddableAdGroupCriterion).Criterion.(KeywordCriterion)
		fmt.Printf("\tKeyword ID is %d and type is '%s'", k.Id, k.MatchType)
	}
}

// This example updates the bid of a keyword.
keywordCriterion := adGroupCriterions[0].(BiddableAdGroupCriterion).Criterion.(KeywordCriterion)
biddingStrategyConfigurations := BiddingStrategyConfiguration{
	Bids: []Bid{
		Bid{
			Type:   "CpcBid",
			Amount: 10000000,
		},
	},
}
adGroupCriterions, err = agcs.Mutate(
	AdGroupCriterionOperations{
		"SET": {
			BiddableAdGroupCriterion{
				AdGroupId:                    adGroupId,
				Criterion:                    keywordCriterion,
				BiddingStrategyConfiguration: &biddingStrategyConfigurations,
			},
		},
	},
)
biddableAdGroupCriterion := adGroupCriterions[0].(BiddableAdGroupCriterion)
keywordCriterion = biddableAdGroupCriterion.Criterion.(KeywordCriterion)
if err != nil {
	fmt.Printf("No keywords were updated.")
} else {
	fmt.Printf("Keyword ID %d was successfully updated, current bids are:", keywordCriterion.Id)
	for _, bid := range biddableAdGroupCriterion.BiddingStrategyConfiguration.Bids {
		fmt.Printf("\tType: '%s', value: %d", bid.Type, bid.Amount)
	}
}

// This example removes a keyword using the 'REMOVE' operator.
adGroupCriterions, err = agcs.Mutate(
	AdGroupCriterionOperations{
		"REMOVE": {
			BiddableAdGroupCriterion{
				AdGroupId: adGroupId,
				Criterion: keywordCriterion,
			},
		},
	},
)
if err != nil {
	fmt.Printf("No keywords were removed.")
} else {
	biddableAdGroupCriterion := adGroupCriterions[0].(BiddableAdGroupCriterion)
	keywordCriterion = biddableAdGroupCriterion.Criterion.(KeywordCriterion)
	fmt.Printf("Keyword ID %d was successfully removed.", keywordCriterion.Id)
}
Output:

func (*AdGroupCriterionService) MutateLabel

func (s *AdGroupCriterionService) MutateLabel(adGroupCriterionLabelOperations AdGroupCriterionLabelOperations) (adGroupCriterionLabels []AdGroupCriterionLabel, err error)

MutateLabel allows you to add and removes labels from ad groups.

Example

adGroupCriterions, err := adGroupCriterionService.MutateLabel(
  gads.AdGroupCriterionLabelOperations{
    "ADD": {
      gads.AdGroupCriterionLabel{AdGroupCriterionId: 3200, LabelId: 5353},
      gads.AdGroupCriterionLabel{AdGroupCriterionId: 4320, LabelId: 5643},
    },
    "REMOVE": {
      gads.AdGroupCriterionLabel{AdGroupCriterionId: 3653, LabelId: 5653},
    },
  },
)

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupCriterionService#mutateLabel

func (*AdGroupCriterionService) Query

func (s *AdGroupCriterionService) Query(query string) (adGroupCriterions AdGroupCriterions, err error)

Query is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupCriterionService#query

type AdGroupCriterions

type AdGroupCriterions []interface{}

func (*AdGroupCriterions) UnmarshalXML

func (agcs *AdGroupCriterions) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error

type AdGroupFeed

type AdGroupFeed struct {
}

type AdGroupFeedOperations

type AdGroupFeedOperations struct {
}

type AdGroupFeedService

type AdGroupFeedService struct {
	Auth
}

func NewAdGroupFeedService

func NewAdGroupFeedService(auth *Auth) *AdGroupFeedService

func (AdGroupFeedService) Get

func (s AdGroupFeedService) Get(selector Selector) (adGroupFeeds []AdGroupFeed, err error)

Get is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupFeedService#get

func (*AdGroupFeedService) Mutate

func (s *AdGroupFeedService) Mutate(adGroupFeedOperations AdGroupFeedOperations) (adGroupFeeds []AdGroupFeed, err error)

Mutate is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupFeedService#mutate

func (*AdGroupFeedService) Query

func (s *AdGroupFeedService) Query(query string) (adGroupFeeds []AdGroupFeed, err error)

Query is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupFeedService#query

type AdGroupLabel

type AdGroupLabel struct {
	AdGroupId int64 `xml:"adGroupId"`
	LabelId   int64 `xml:"labelId"`
}

type AdGroupLabelOperations

type AdGroupLabelOperations map[string][]AdGroupLabel

type AdGroupOperations

type AdGroupOperations map[string][]AdGroup

type AdGroupService

type AdGroupService struct {
	Auth
}

func NewAdGroupService

func NewAdGroupService(auth *Auth) *AdGroupService

func (*AdGroupService) Get

func (s *AdGroupService) Get(selector Selector) (adGroups []AdGroup, totalCount int64, err error)

Get returns an array of ad group's and the total number of ad group's matching the selector.

Example

ads, totalCount, err := adGroupService.Get(
  gads.Selector{
    Fields: []string{
      "Id",
      "CampaignId",
      "CampaignName",
      "Name",
      "Status",
      "Settings",
      "Labels",
      "ContentBidCriterionTypeGroup",
      "TrackingUrlTemplate",
      "UrlCustomParameters",
    },
    Predicates: []gads.Predicate{
      {"Id", "EQUALS", []string{adGroupId}},
    },
  },
)

Selectable fields are

"Id", "CampaignId", "CampaignName", "Name", "Status", "Settings", "Labels"
"ContentBidCriterionTypeGroup", "TrackingUrlTemplate", "UrlCustomParameters"

filterable fields are

"Id", "CampaignId", "CampaignName", "Name", "Status", "Labels"
"ContentBidCriterionTypeGroup", "TrackingUrlTemplate"

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupService#get
Example
authConf, _ := NewCredentials(context.TODO())
ags := NewAdGroupService(&authConf.Auth)

// This example illustrates how to retrieve all the ad groups for a campaign.
campaignId := "3"
var pageSize int64 = 500
var offset int64 = 0
paging := Paging{
	Offset: offset,
	Limit:  pageSize,
}
totalCount := 0
for {
	adGroups, totalCount, err := ags.Get(
		Selector{
			Fields: []string{
				"Id",
				"Name",
			},
			Ordering: []OrderBy{
				{"Name", "ASCENDING"},
			},
			Predicates: []Predicate{
				{"CampaignId", "IN", []string{campaignId}},
			},
			Paging: &paging,
		},
	)
	if err != nil {
		fmt.Printf("Error occured finding ad group")
	}
	for _, ag := range adGroups {
		fmt.Printf("Ad group name is '%s' and ID is %d", ag.Id, ag.Name)
	}
	// Increment values to request the next page.
	offset += pageSize
	paging.Offset = offset
	if totalCount < offset {
		break
	}
}
fmt.Printf("\tCampaign ID %d has %d ad group(s).", campaignId, totalCount)
Output:

func (*AdGroupService) Mutate

func (s *AdGroupService) Mutate(adGroupOperations AdGroupOperations) (adGroups []AdGroup, err error)

Mutate allows you to add, modify and remove ad group's, returning the modified ad group's.

Example

ads, err := adGroupService.Mutate(
  gads.AdGroupOperations{
    "ADD": {
      gads.AdGroup{
        Name:       "my ad group ",
        Status:     "PAUSED",
        CampaignId:  campaignId,
        BiddingStrategyConfiguration: []gads.BiddingStrategyConfiguration{
          gads.BiddingStrategyConfiguration{
            StrategyType: "MANUAL_CPC",
            Bids: []gads.Bid{
              gads.Bid{
                Type:   "CpcBid",
                Amount: 10000,
              },
            },
          },
        },
      },
    },
    "SET": {
      modifiedAdGroup,
    },
    "REMOVE": {
      adGroupNeedingRemoval,
    },
  },
)

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupService#mutate
Example
authConf, err := NewCredentials(context.TODO())
ags := NewAdGroupService(&authConf.Auth)

var campaignId int64 = 1

// This example illustrates how to create ad groups.
adGroups, err := ags.Mutate(
	AdGroupOperations{
		"ADD": {
			AdGroup{
				Name:       fmt.Sprintf("Earth to Mars Cruises #%d", time.Now().Unix()),
				Status:     "ENABLED",
				CampaignId: campaignId,
				BiddingStrategyConfiguration: []BiddingStrategyConfiguration{
					{
						Bids: []Bid{
							Bid{
								Type:   "CpcBid",
								Amount: 10000000,
							},
						},
					},
				},
				Settings: []AdSetting{
					AdSetting{
						Details: []TargetSettingDetail{
							TargetSettingDetail{
								CriterionTypeGroup: "PLACEMENT",
								TargetAll:          true,
							},
							TargetSettingDetail{
								CriterionTypeGroup: "VERTICAL",
								TargetAll:          false,
							},
						},
					},
				},
			},
			AdGroup{
				Name:       fmt.Sprintf("Earth to Pluto Cruises #%d", time.Now().Unix()),
				Status:     "ENABLED",
				CampaignId: campaignId,
				BiddingStrategyConfiguration: []BiddingStrategyConfiguration{
					{
						Bids: []Bid{
							Bid{
								Type:   "CpcBid",
								Amount: 10000000,
							},
						},
					},
				},
			},
		},
	},
)
if err != nil {
	fmt.Printf("")
} else {
	for _, ag := range adGroups {
		fmt.Printf("Ad group ID %d was successfully added.", ag.Id)
	}
}

// This example illustrates how to update an ad group
adGroups, err = ags.Mutate(
	AdGroupOperations{
		"SET": {
			AdGroup{
				Id:     adGroups[0].Id,
				Status: "PAUSE",
			},
		},
	},
)
if err != nil {
	fmt.Printf("No ad groups were updated.")
} else {
	fmt.Printf("Ad group id %d was successfully updated.", adGroups[0].Id)
}

// This example removes an ad group by setting the status to 'REMOVED'.
adGroups, err = ags.Mutate(
	AdGroupOperations{
		"SET": {
			AdGroup{
				Id:     adGroups[0].Id,
				Status: "REMOVE",
			},
		},
	},
)
if err != nil {
	fmt.Printf("No ad groups were updated.")
} else {
	fmt.Printf("Ad group id %d was successfully removed.", adGroups[0].Id)
}
Output:

func (*AdGroupService) MutateLabel

func (s *AdGroupService) MutateLabel(adGroupLabelOperations AdGroupLabelOperations) (adGroupLabels []AdGroupLabel, err error)

MutateLabel allows you to add and removes labels from ad groups.

Example

adGroups, err := adGroupService.MutateLabel(
  gads.AdGroupLabelOperations{
    "ADD": {
      gads.AdGroupLabel{AdGroupId: 3200, LabelId: 5353},
      gads.AdGroupLabel{AdGroupId: 4320, LabelId: 5643},
    },
    "REMOVE": {
      gads.AdGroupLabel{AdGroupId: 3653, LabelId: 5653},
    },
  }

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupService#mutateLabel

func (*AdGroupService) Query

func (s *AdGroupService) Query(query string) (adGroups []AdGroup, err error)

Query is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupService#query

type AdGroupServiceError

type AdGroupServiceError struct {
	FieldPath   string `xml:"fieldPath"`
	Trigger     string `xml:"trigger"`
	ErrorString string `xml:"errorString"`
	Reason      string `xml:"reason"`
}

type AdParam

type AdParam struct {
}

type AdParamService

type AdParamService struct {
	Auth
}

func NewAdParamService

func NewAdParamService(auth *Auth) *AdParamService

func (AdParamService) Get

func (s AdParamService) Get(selector Selector) (adParams []AdParam, err error)

Query is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdParamService#get

type AdScheduleCriterion

type AdScheduleCriterion struct {
	Type        string `xml:"xsi:type,attr,omitempty"`
	Id          int64  `xml:"id,omitempty"`
	DayOfWeek   string `xml:"dayOfWeek"`
	StartHour   string `xml:"startHour"`
	StartMinute string `xml:"startMinute"`
	EndHour     string `xml:"endHour"`
	EndMinute   string `xml:"endMinute"`
}

DayOfWeek: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY StartHour: 0~23 inclusive StartMinute: ZERO, FIFTEEN, THIRTY, FORTY_FIVE EndHour: 0~24 inclusive EndMinute: ZERO, FIFTEEN, THIRTY, FORTY_FIVE

func (AdScheduleCriterion) GetID

func (c AdScheduleCriterion) GetID() int64

type AdSetting

type AdSetting struct {
	XMLName xml.Name `xml:"settings"`
	Type    string   `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"`

	OptIn   *bool                 `xml:"optIn"`
	Details []TargetSettingDetail `xml:"details"`
}

type AdURLUpgrade

type AdURLUpgrade struct {
	AdId                int64  `xml:"adId"`
	FinalURL            string `xml:"finalUrl,omitempty"`
	FinalMobileUrl      string `xml:"finalMobileUrl,omitempty"`
	TrackingURLTemplate string `xml:"trackingUrlTemplate"`
}

type Address

type Address struct {
	StreetAddress  string `xml:"streetAddress"`
	StreetAddress2 string `xml:"streetAddress2"`
	CityName       string `xml:"cityName"`
	ProvinceCode   string `xml:"provinceCode"`
	ProvinceName   string `xml:"provinceName"`
	PostalCode     string `xml:"postalCode"`
	CountryCode    string `xml:"countryCode"`
}

type AdwordsUserListService

type AdwordsUserListService struct {
	Auth
}

func NewAdwordsUserListService

func NewAdwordsUserListService(auth *Auth) *AdwordsUserListService

func (AdwordsUserListService) Get

func (s AdwordsUserListService) Get(selector Selector) (userLists []UserList, err error)

Get returns an array of adwords user lists and the total number of adwords user lists matching the selector.

Example

ads, totalCount, err := adwordsUserListService.Get(
  gads.Selector{
    Fields: []string{
      "Id",
      "Name",
      "Status",
      "Labels",
    },
    Predicates: []gads.Predicate{
      {"Id", "EQUALS", []string{adGroupId}},
    },
  },
)

Selectable fields are

"Id", "IsReadOnly", "Name", "Description", "Status", "IntegrationCode", "AccessReason",
"AccountUserListStatus", "MembershipLifeSpan", "Size", "SizeRange", "SizeForSearch",
"SizeRangeForSearch", "ListType"

BasicUserList
  "ConversionType"

LogicalUserList
  "Rules"

SimilarUserList
  "SeedUserListId", "SeedUserListName", "SeedUserListDescription", "SeedUserListStatus",
  "SeedListSize"

filterable fields are

"Id", "Name", "Status", "IntegrationCode", "AccessReason", "AccountUserListStatus",
"MembershipLifeSpan", "Size", "SizeForSearch", "ListType"

SimilarUserList
  "SeedUserListId", "SeedListSize"

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdwordsUserListService#get

func (*AdwordsUserListService) Mutate

func (s *AdwordsUserListService) Mutate(adwordsUserListOperations UserListOperations) (adwordsUserLists []UserList, err error)

Mutate is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/AdwordsUserListService#mutate

type AgeRangeCriterion

type AgeRangeCriterion struct {
	Type         string `xml:"xsi:type,attr,omitempty"`
	Id           int64  `xml:"id,omitempty"`
	AgeRangeType string `xml:"ageRangeType"`
}

AgeRangeType: AGE_RANGE_18_24, AGE_RANGE_25_34, AGE_RANGE_35_44, AGE_RANGE_45_54, AGE_RANGE_55_64, AGE_RANGE_65_UP, AGE_RANGE_UNDETERMINED, UNKNOWN

func (AgeRangeCriterion) GetID

func (c AgeRangeCriterion) GetID() int64

type ApiExceptionFault

type ApiExceptionFault struct {
	Message string        `xml:"message"`
	Type    string        `xml:"ApplicationException.Type"`
	Errors  []interface{} `xml:"errors"`
}

func (*ApiExceptionFault) UnmarshalXML

func (aes *ApiExceptionFault) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) (err error)

type AppUrl

type AppUrl struct {
	Url    string `xml:"url"`
	OsType string `xml:"osType"` // "OS_TYPE_IOS", "OS_TYPE_ANDROID", "UNKNOWN"
}

type Auth

type Auth struct {
	CustomerId     string
	DeveloperToken string
	UserAgent      string
	Testing        *testing.T   `json:"-"`
	Client         *http.Client `json:"-"`
}

type AuthConfig

type AuthConfig struct {
	OAuth2Config *oauth2.Config `json:"oauth2.Config"`
	OAuth2Token  *oauth2.Token  `json:"oauth2.Token"`

	Auth Auth `json:"gads.Auth"`
	// contains filtered or unexported fields
}

func NewCredentials

func NewCredentials(ctx context.Context) (ac AuthConfig, err error)

func NewCredentialsFromFile

func NewCredentialsFromFile(pathToFile string, ctx context.Context) (ac AuthConfig, err error)

func (AuthConfig) Save

func (c AuthConfig) Save() error

Save writes the contents of AuthConfig back to the JSON file it was loaded from.

func (AuthConfig) Token

func (c AuthConfig) Token() (token *oauth2.Token, err error)

Token implements oauth2.TokenSource interface and store updates to config file.

type Bid

type Bid struct {
	Type         string  `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"`
	Amount       int64   `xml:"bid>microAmount"`
	CpcBidSource *string `xml:"cpcBidSource"`
	CpmBidSource *string `xml:"cpmBidSource"`
}

type BiddableAdGroupCriterion

type BiddableAdGroupCriterion struct {
	Type      string    `xml:"xsi:type,attr,omitempty"`
	AdGroupId int64     `xml:"adGroupId"`
	Criterion Criterion `xml:"criterion"`

	// BiddableAdGroupCriterion
	UserStatus          string   `xml:"userStatus,omitempty"`
	SystemServingStatus string   `xml:"systemServingStatus,omitempty"`
	ApprovalStatus      string   `xml:"approvalStatus,omitempty"`
	DisapprovalReasons  []string `xml:"disapprovalReasons,omitempty"`
	DestinationUrl      string   `xml:"destinationUrl,omitempty"`

	FirstPageCpc *Cpc `xml:"firstPageCpc>amount,omitempty"`
	TopOfPageCpc *Cpc `xml:"topOfPageCpc>amount,omitempty"`

	QualityInfo *QualityInfo `xml:"qualityInfo,omitempty"`

	BiddingStrategyConfiguration *BiddingStrategyConfiguration `xml:"biddingStrategyConfiguration,omitempty"`
	BidModifier                  int64                         `xml:"bidModifier,omitempty"`
	FinalUrls                    *FinalURLs                    `xml:"finalUrls,omitempty"`
	FinalMobileUrls              []string                      `xml:"finalMobileUrls,omitempty"`
	FinalAppUrls                 []string                      `xml:"finalAppUrls,omitempty"`
	TrackingUrlTemplate          *string                       `xml:"trackingUrlTemplate,omitempty"`
	UrlCustomParameters          *CustomParameters             `xml:"urlCustomParameters,omitempty"`
}

func (*BiddableAdGroupCriterion) UnmarshalXML

func (bagc *BiddableAdGroupCriterion) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error

type BiddingScheme

type BiddingScheme struct {
	Type               string `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"`
	EnhancedCpcEnabled bool   `xml:"enhancedCpcEnabled"`
}

type BiddingStrategyConfiguration

type BiddingStrategyConfiguration struct {
	StrategyId     int64          `xml:"biddingStrategyId,omitempty"`
	StrategyName   string         `xml:"biddingStrategyName,omitempty"`
	StrategyType   string         `xml:"biddingStrategyType,omitempty"`
	StrategySource string         `xml:"biddingStrategySource,omitempty"`
	Scheme         *BiddingScheme `xml:"biddingScheme,omitempty"`
	Bids           []Bid          `xml:"bids"`
}

type BiddingStrategyService

type BiddingStrategyService struct {
	Auth
}

func NewBiddingStrategyService

func NewBiddingStrategyService(auth *Auth) *BiddingStrategyService

type Budget

type Budget struct {
	Id         int64  `xml:"budgetId,omitempty"`           // A unique identifier
	Name       string `xml:"name"`                         // A descriptive name
	Period     string `xml:"period"`                       // The period to spend the budget
	Amount     int64  `xml:"amount>microAmount"`           // The amount in cents
	Delivery   string `xml:"deliveryMethod"`               // The rate at which the budget spent. valid options are STANDARD or ACCELERATED.
	References int64  `xml:"referenceCount,omitempty"`     // The number of campaigns using the budget
	Shared     bool   `xml:"isExplicitlyShared,omitempty"` // If this budget was created to be shared across campaigns
	Status     string `xml:"status,omitempty"`             // The status of the budget. can be ENABLED, REMOVED, UNKNOWN
}

A Budget represents an allotment of money to be spent over a fixed period of time.

type BudgetError

type BudgetError struct {
	Path    string `xml:"fieldPath"`
	String  string `xml:"errorString"`
	Trigger string `xml:"trigger"`
	Reason  string `xml:"reason"`
}

type BudgetOperations

type BudgetOperations map[string][]Budget

A BudgetOperations maps operations to the budgets they will be performed on. Budgets operations can be 'ADD', 'REMOVE' or 'SET'

type BudgetOrderService

type BudgetOrderService struct {
	Auth
}

func NewBudgetOrderService

func NewBudgetOrderService(auth *Auth) *BudgetOrderService

type BudgetService

type BudgetService struct {
	Auth
}

A budgetService holds the connection information for the budget service.

func NewBudgetService

func NewBudgetService(auth *Auth) *BudgetService

NewBudgetService creates a new budgetService

func (*BudgetService) Get

func (s *BudgetService) Get(selector Selector) (budgets []Budget, totalCount int64, err error)

Get returns budgets matching a given selector and the total count of matching budgets.

func (*BudgetService) Mutate

func (s *BudgetService) Mutate(budgetOperations BudgetOperations) (budgets []Budget, err error)

Mutate takes a budgetOperations and creates, modifies or destroys the associated budgets.

type Campaign

type Campaign struct {
	Id                             int64                           `xml:"id,omitempty"`
	Name                           string                          `xml:"name,omitempty"`
	Status                         string                          `xml:"status,omitempty"`        // Status: "ENABLED", "PAUSED", "REMOVED"
	ServingStatus                  *string                         `xml:"servingStatus,omitempty"` // ServingStatus: "SERVING", "NONE", "ENDED", "PENDING", "SUSPENDED"
	StartDate                      string                          `xml:"startDate,omitempty"`
	EndDate                        *string                         `xml:"endDate,omitempty"`
	BudgetId                       int64                           `xml:"budget>budgetId,omitempty"`
	ConversionOptimizerEligibility *conversionOptimizerEligibility `xml:"conversionOptimizerEligibility,omitempty"`
	AdServingOptimizationStatus    string                          `xml:"adServingOptimizationStatus,omitempty"`
	FrequencyCap                   *FrequencyCap                   `xml:"frequencyCap,omitempty"`
	Settings                       []CampaignSetting               `xml:"settings"`
	AdvertisingChannelType         string                          `xml:"advertisingChannelType,omitempty"`    // "UNKNOWN", "SEARCH", "DISPLAY", "SHOPPING"
	AdvertisingChannelSubType      *string                         `xml:"advertisingChannelSubType,omitempty"` // "UNKNOWN", "SEARCH_MOBILE_APP", "DISPLAY_MOBILE_APP", "SEARCH_EXPRESS", "DISPLAY_EXPRESS"
	NetworkSetting                 *NetworkSetting                 `xml:"networkSetting"`
	Labels                         []Label                         `xml:"labels,omitempty"`
	BiddingStrategyConfiguration   *BiddingStrategyConfiguration   `xml:"biddingStrategyConfiguration,omitempty"`
	ForwardCompatibilityMap        *map[string]string              `xml:"forwardCompatibilityMap,omitempty"`
	TrackingUrlTemplate            *string                         `xml:"trackingUrlTemplate,omitempty"`
	UrlCustomParameters            *CustomParameters               `xml:"urlCustomParameters,omitempty"`
	Errors                         []error                         `xml:"-"`
}

type CampaignAdExtensionService

type CampaignAdExtensionService struct {
	Auth
}

func NewCampaignAdExtensionService

func NewCampaignAdExtensionService(auth *Auth) *CampaignAdExtensionService

type CampaignCriterion

type CampaignCriterion struct {
	CampaignId  int64     `xml:"campaignId"`
	Criterion   Criterion `xml:"criterion"`
	BidModifier float64   `xml:"bidModifier,omitempty"`
	Errors      []error   `xml:"-"`
}

func (CampaignCriterion) MarshalXML

func (cc CampaignCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type CampaignCriterionOperations

type CampaignCriterionOperations map[string]CampaignCriterions

type CampaignCriterionService

type CampaignCriterionService struct {
	Auth
}

func NewCampaignCriterionService

func NewCampaignCriterionService(auth *Auth) *CampaignCriterionService

func (*CampaignCriterionService) Get

func (s *CampaignCriterionService) Get(selector Selector) (campaignCriterions CampaignCriterions, totalCount int64, err error)

func (*CampaignCriterionService) Mutate

func (s *CampaignCriterionService) Mutate(campaignCriterionOperations CampaignCriterionOperations) (campaignCriterions CampaignCriterions, err error)

func (*CampaignCriterionService) Query

func (s *CampaignCriterionService) Query(query string) (campaignCriterions CampaignCriterions, err error)

type CampaignCriterions

type CampaignCriterions []interface{}

func (*CampaignCriterions) UnmarshalXML

func (ccs *CampaignCriterions) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error

type CampaignFeedService

type CampaignFeedService struct {
	Auth
}

func NewCampaignFeedService

func NewCampaignFeedService(auth *Auth) *CampaignFeedService

type CampaignLabel

type CampaignLabel struct {
	CampaignId int64 `xml:"campaignId"`
	LabelId    int64 `xml:"labelId"`
}

type CampaignLabelOperations

type CampaignLabelOperations map[string][]CampaignLabel

type CampaignOperations

type CampaignOperations map[string][]Campaign

type CampaignService

type CampaignService struct {
	Auth
}

A campaignService holds the connection information for the campaign service.

func NewCampaignService

func NewCampaignService(auth *Auth) *CampaignService

NewCampaignService creates a new campaignService

func (*CampaignService) Get

func (s *CampaignService) Get(selector Selector) (campaigns []Campaign, totalCount int64, err error)

Get returns an array of Campaign's and the total number of campaign's matching the selector.

Example

campaigns, totalCount, err := campaignService.Get(
  gads.Selector{
    Fields: []string{
      "AdGroupId",
      "Status",
      "AdGroupCreativeApprovalStatus",
      "AdGroupAdDisapprovalReasons",
      "AdGroupAdTrademarkDisapproved",
    },
    Predicates: []gads.Predicate{
      {"AdGroupId", "EQUALS", []string{adGroupId}},
    },
  },
)

Selectable fields are

"Id", "Name", "Status", "ServingStatus", "StartDate", "EndDate", "AdServingOptimizationStatus",
"Settings", "AdvertisingChannelType", "AdvertisingChannelSubType", "Labels", "TrackingUrlTemplate",
"UrlCustomParameters"

filterable fields are

"Id", "Name", "Status", "ServingStatus", "StartDate", "EndDate", "AdvertisingChannelType",
"AdvertisingChannelSubType", "Labels", "TrackingUrlTemplate"

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/CampaignService#get
Example
// load credentials from
authConf, _ := NewCredentials(context.TODO())
cs := NewCampaignService(&authConf.Auth)

// This example illustrates how to retrieve all the campaigns for an account.
var pageSize int64 = 500
var offset int64 = 0
paging := Paging{
	Offset: offset,
	Limit:  pageSize,
}
totalCount := 0
for {
	campaigns, totalCount, err := cs.Get(
		Selector{
			Fields: []string{
				"Id",
				"Name",
				"Status",
			},
			Ordering: []OrderBy{
				{"Name", "ASCENDING"},
			},
			Paging: &paging,
		},
	)
	if err != nil {
		fmt.Printf("Error occured finding campaigns")
	}
	for _, c := range campaigns {
		fmt.Printf("Campaign ID %d, name '%s' and status '%s'", c.Id, c.Name, c.Status)
	}
	// Increment values to request the next page.
	offset += pageSize
	paging.Offset = offset
	if totalCount < offset {
		break
	}
}
fmt.Printf("\tTotal number of campaigns found: %d.", totalCount)
Output:

func (*CampaignService) Mutate

func (s *CampaignService) Mutate(campaignOperations CampaignOperations) (campaigns []Campaign, err error)

Mutate allows you to add and modify campaigns, returning the campaigns. Note that the "REMOVE" operator is not supported. To remove a campaign set its Status to "REMOVED".

Example

campaignNeedingRemoval.Status = "REMOVED"
ads, err := campaignService.Mutate(
  gads.CampaignOperations{
    "ADD": {
      gads.Campaign{
        Name: "my campaign name",
        Status: "PAUSED",
        StartDate: time.Now().Format("20060102"),
        BudgetId: 321543214,
        AdServingOptimizationStatus: "ROTATE_INDEFINITELY",
        Settings: []gads.CampaignSetting{
          gads.NewRealTimeBiddingSetting(true),
        },
        AdvertisingChannelType: "SEARCH",
        BiddingStrategyConfiguration: &gads.BiddingStrategyConfiguration{
          StrategyType: "MANUAL_CPC",
        },
      },
      campaignNeedingRemoval,
    },
    "SET": {
      modifiedCampaign,
    },
  }

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/CampaignService#mutate
Example
// load credentials from
authConf, err := NewCredentials(context.TODO())
cs := NewCampaignService(&authConf.Auth)

var budgetId int64 = 1

// This example illustrates how to create campaigns.
campaigns, err := cs.Mutate(
	CampaignOperations{
		"ADD": {
			Campaign{
				Name:   fmt.Sprintf("Interplanetary Cruise #%d", time.Now().Unix()),
				Status: "ACTIVE",
				BiddingStrategyConfiguration: &BiddingStrategyConfiguration{
					StrategyType: "MANUAL_CPC",
				},
				// Budget (required) - note only the budget ID is required
				BudgetId:               budgetId,
				AdvertisingChannelType: "SEARCH",
				// Optional Fields:
				StartDate:                   time.Now().Format("20060102"),
				AdServingOptimizationStatus: "ROTATE",
				NetworkSetting: &NetworkSetting{
					TargetGoogleSearch:         true,
					TargetSearchNetwork:        true,
					TargetContentNetwork:       false,
					TargetPartnerSearchNetwork: false,
				},
				Settings: []CampaignSetting{
					NewGeoTargetTypeSetting(
						"DONT_CARE",
						"DONT_CARE",
					),
				},
				FrequencyCap: &FrequencyCap{
					Impressions: 5,
					TimeUnit:    "DAY",
					Level:       "ADGROUP",
				},
			},
			Campaign{
				Name:   fmt.Sprintf("Interplanetary Cruise banner #%d", time.Now().Unix()),
				Status: "PAUSED",
				BiddingStrategyConfiguration: &BiddingStrategyConfiguration{
					StrategyType: "MANUAL_CPC",
				},
				// Budget (required) - note only the budget ID is required
				BudgetId:               budgetId,
				AdvertisingChannelType: "DISPLAY",
			},
		},
	},
)
if err != nil {
	fmt.Printf("Error occured creating campaign.")
}
for _, c := range campaigns {
	fmt.Printf("Campaign with name '%s' and ID %d was added.", c.Name, c.Id)
}

// This example illustrates how to update a campaign, setting its status to 'PAUSED'
campaigns, err = cs.Mutate(
	CampaignOperations{
		"SET": {
			Campaign{
				Id:     campaigns[0].Id,
				Status: "PAUSED",
			},
		},
	},
)
if err != nil {
	fmt.Printf("No campaigns were updated.")
} else {
	fmt.Printf("Campaign ID %d was successfully updated, status was set to '%s'.", campaigns[0].Id, campaigns[0].Status)
}

// This example removes a campaign by setting the status to 'REMOVED'.
campaigns, err = cs.Mutate(
	CampaignOperations{
		"SET": {
			Campaign{
				Id:     campaigns[0].Id,
				Status: "REMOVED",
			},
		},
	},
)
if err != nil {
	fmt.Printf("No campaigns were updated.")
} else {
	fmt.Printf("Campaign ID %d was removed.", campaigns[0].Id)
}
Output:

func (*CampaignService) MutateLabel

func (s *CampaignService) MutateLabel(campaignLabelOperations CampaignLabelOperations) (campaignLabels []CampaignLabel, err error)

Mutate allows you to add and removes labels from campaigns.

Example

cls, err := campaignService.MutateLabel(
  gads.CampaignOperations{
    "ADD": {
      gads.CampaignLabel{CampaignId: 3200, LabelId: 5353},
      gads.CampaignLabel{CampaignId: 4320, LabelId: 5643},
    },
    "REMOVE": {
      gads.CampaignLabel{CampaignId: 3653, LabelId: 5653},
    },
  }

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/CampaignService#mutateLabel

func (*CampaignService) Query

func (s *CampaignService) Query(query string) (campaigns []Campaign, totalCount int64, err error)

Query is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/CampaignService#query

type CampaignSetting

type CampaignSetting struct {
	XMLName xml.Name `xml:"settings"`
	Type    string   `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"`

	// GeoTargetTypeSetting
	PositiveGeoTargetType *string `xml:"positiveGeoTargetType,omitempty"`
	NegativeGeoTargetType *string `xml:"negativeGeoTargetType,omitempty"`

	// RealTimeBiddingSetting
	OptIn *bool `xml:"optIn,omitempty"`

	// DynamicSearchAdsSetting
	DomainName   *string `xml:"domainName,omitempty"`
	LanguageCode *string `xml:"langaugeCode,omitempty"`

	// TrackingSetting
	TrackingUrl *string `xml:"trackingUrl,omitempty"`
}

func NewDynamicSearchAdsSetting

func NewDynamicSearchAdsSetting(domainName, languageCode string) CampaignSetting

func NewGeoTargetTypeSetting

func NewGeoTargetTypeSetting(positiveGeoTargetType, negativeGeoTargetType string) CampaignSetting

func NewRealTimeBiddingSetting

func NewRealTimeBiddingSetting(optIn bool) CampaignSetting

func NewTrackingSetting

func NewTrackingSetting(trackingUrl string) CampaignSetting

type CampaignSharedSetService

type CampaignSharedSetService struct {
	Auth
}

func NewCampaignSharedSetService

func NewCampaignSharedSetService(auth *Auth) *CampaignSharedSetService

type CarrierCriterion

type CarrierCriterion struct {
	Type        string `xml:"xsi:type,attr,omitempty"`
	Id          int64  `xml:"id,omitempty"`
	Name        string `xml:"name,emitempty"`
	CountryCode string `xml:"countryCode,emitempty"`
}

func (CarrierCriterion) GetID

func (c CarrierCriterion) GetID() int64

type CommonAd

type CommonAd struct {
	Type                string            `xml:"xsi:type,attr,omitempty"`
	ID                  int64             `xml:"id,omitempty"`
	URL                 string            `xml:"url,omitempty"`
	DisplayURL          string            `xml:"displayUrl,omitempty"`
	FinalURLs           []string          `xml:"finalUrls,omitempty"`
	FinalMobileURLs     []string          `xml:"finalMobileUrls,omitempty"`
	FinalAppURLs        []AppUrl          `xml:"finalAppUrls,omitempty"`
	TrackingURLTemplate *string           `xml:"trackingUrlTemplate,omitempty"`
	URLCustomParameters *CustomParameters `xml:"urlCustomParameters,omitempty"`
	DevicePreference    int64             `xml:"devicePreference,omitempty"`
}

CommonAd define the parent type Ad type as defined https://developers.google.com/adwords/api/docs/reference/v201506/AdGroupAdService.Ad

func (CommonAd) CloneForTemplate

func (c CommonAd) CloneForTemplate(finalURLs []string, trackingURLTemplate *string) Ad

CloneForTemplate create a clone of an Ad, to recreate it for changing the tracking Url Template (as Ad are immutable)

func (CommonAd) GetFinalURLs

func (c CommonAd) GetFinalURLs() []string

GetFinalURLs returns the list of Final urls (can be empty array)

func (CommonAd) GetID

func (c CommonAd) GetID() int64

GetID returns the Ad's id

func (CommonAd) GetTrackingURLTemplate

func (c CommonAd) GetTrackingURLTemplate() *string

GetTrackingURLTemplate returns the tracking url template

func (CommonAd) GetURL

func (c CommonAd) GetURL() string

GetURL returns the Ad's url (a.k.a destination url)

type ConstantDataService

type ConstantDataService struct {
	Auth
}

func NewConstantDataService

func NewConstantDataService(auth *Auth) *ConstantDataService

func (*ConstantDataService) GetAgeRangeCriterion

func (s *ConstantDataService) GetAgeRangeCriterion() (ageRanges []AgeRangeCriterion, err error)

func (*ConstantDataService) GetCarrierCriterion

func (s *ConstantDataService) GetCarrierCriterion() (carriers []CarrierCriterion, err error)

func (*ConstantDataService) GetGenderCriterion

func (s *ConstantDataService) GetGenderCriterion() (genders []GenderCriterion, err error)

func (*ConstantDataService) GetLanguageCriterion

func (s *ConstantDataService) GetLanguageCriterion() (languages []LanguageCriterion, err error)

func (*ConstantDataService) GetMobileDeviceCriterion

func (s *ConstantDataService) GetMobileDeviceCriterion() (mobileDevices []MobileDeviceCriterion, err error)

func (*ConstantDataService) GetOperatingSystemVersionCriterion

func (s *ConstantDataService) GetOperatingSystemVersionCriterion() (operatingSystemVersions []OperatingSystemVersionCriterion, err error)

func (*ConstantDataService) GetUserInterestCriterion

func (s *ConstantDataService) GetUserInterestCriterion() (userInterests []UserInterestCriterion, err error)

func (*ConstantDataService) GetVerticalCriterion

func (s *ConstantDataService) GetVerticalCriterion() (verticals []VerticalCriterion, err error)

type ContentLabelCriterion

type ContentLabelCriterion struct {
	Type             string `xml:"xsi:type,attr,omitempty"`
	Id               int64  `xml:"id,omitempty"`
	ContentLabelType string `xml:"contentLabelType"` // ContentLabelType: "ADULTISH", "AFE", "BELOW_THE_FOLD", "CONFLICT", "DP", "EMBEDDED_VIDEO", "GAMES", "JACKASS", "PROFANITY", "UGC_FORUMS", "UGC_IMAGES", "UGC_SOCIAL", "UGC_VIDEOS", "SIRENS", "TRAGEDY", "VIDEO", "UNKNOWN"
}

func (ContentLabelCriterion) GetID

func (c ContentLabelCriterion) GetID() int64

type ConversionTrackerService

type ConversionTrackerService struct {
	Auth
}

func NewConversionTrackerService

func NewConversionTrackerService(auth *Auth) *ConversionTrackerService

type Cpc

type Cpc struct {
	Amount int64 `xml:"amount"`
}

type Criterion

type Criterion interface {
	GetID() int64
}

type CriterionError

type CriterionError struct {
	FieldPath   string `xml:"fieldPath"`
	Trigger     string `xml:"trigger"`
	ErrorString string `xml:"errorString"`
	Reason      string `xml:"reason"`
}

type CustomParameter

type CustomParameter struct {
	Key      string `xml:"key"`
	Value    string `xml:"value"`
	IsRemove bool   `xml:"isRemove"`
}

type CustomParameters

type CustomParameters struct {
	CustomParameters []CustomParameter `xml:"parameters"`
	DoReplace        bool              `xml:"doReplace"`
}

type CustomerFeedService

type CustomerFeedService struct {
	Auth
}

func NewCustomerFeedService

func NewCustomerFeedService(auth *Auth) *CustomerFeedService

type CustomerService

type CustomerService struct {
	Auth
}

func NewCustomerService

func NewCustomerService(auth *Auth) *CustomerService

type CustomerSyncService

type CustomerSyncService struct {
	Auth
}

func NewCustomerSyncService

func NewCustomerSyncService(auth *Auth) *CustomerSyncService

type DataService

type DataService struct {
	Auth
}

func NewDataService

func NewDataService(auth *Auth) *DataService

type DateRange

type DateRange struct {
	Min string `xml:"min"`
	Max string `xml:"max"`
}

Selector structs

type DateRuleItem

type DateRuleItem struct {
	Key   string `xml:"key>name"`
	Op    string `xml:"op"` // "UNKNOWN", "EQUALS", "NOT_EQUAL", "BEFORE", "AFTER"
	Value string `xml:"string"`
}

Rule structs

type Dimensions

type Dimensions struct {
	Name   string `xml:"key"` // "FULL", "SHRUNKEN", "PREVIEW", "VIDEO_THUMBNAIL"
	Width  int64  `xml:"value>width"`
	Height int64  `xml:"value>height"`
}

type DynamicSearchAd

type DynamicSearchAd struct {
	CommonAd
	Description1 string `xml:"description1"`
	Description2 string `xml:"description2"`
}

DynamicSearchAd represents the equivalent object documented here https://developers.google.com/adwords/api/docs/reference/v201502/AdGroupAdService.DynamicSearchAd

func (DynamicSearchAd) CloneForTemplate

func (c DynamicSearchAd) CloneForTemplate(finalURLs []string, trackingURLTemplate *string) Ad

CloneForTemplate create a clone of an Ad, to recreate it for changing the tracking Url Template

type ErrorsType

type ErrorsType struct {
	ApiExceptionFaults []ApiExceptionFault `xml:"ApiExceptionFault"`
}

func (ErrorsType) Error

func (f ErrorsType) Error() string

type ExperimentService

type ExperimentService struct {
	Auth
}

func NewExperimentService

func NewExperimentService(auth *Auth) *ExperimentService

type Fault

type Fault struct {
	XMLName     xml.Name   `xml:"Fault"`
	FaultCode   string     `xml:"faultcode"`
	FaultString string     `xml:"faultstring"`
	Errors      ErrorsType `xml:"detail"`
}

func (Fault) Error

func (f Fault) Error() string

type FeedItemService

type FeedItemService struct {
	Auth
}

func NewFeedItemService

func NewFeedItemService(auth *Auth) *FeedItemService

type FeedMappingService

type FeedMappingService struct {
	Auth
}

func NewFeedMappingService

func NewFeedMappingService(auth *Auth) *FeedMappingService

type FeedService

type FeedService struct {
	Auth
}

func NewFeedService

func NewFeedService(auth *Auth) *FeedService

type FinalURLs

type FinalURLs struct {
	URLs []string `xml:"urls,omitempty" json:urls,omitempty`
}

type FrequencyCap

type FrequencyCap struct {
	Impressions int64  `xml:"impressions"`
	TimeUnit    string `xml:"timeUnit"`
	Level       string `xml:"level,omitempty"`
}

type GenderCriterion

type GenderCriterion struct {
	Type       string `xml:"xsi:type,attr,omitempty"`
	Id         int64  `xml:"id,omitempty"`
	GenderType string `xml:"genderType"` // GenderType:  "GENDER_MALE", "GENDER_FEMALE", "GENDER_UNDETERMINED"
}

func (GenderCriterion) GetID

func (c GenderCriterion) GetID() int64

type GeoLocationService

type GeoLocationService struct {
	Auth
}

func NewGeoLocationService

func NewGeoLocationService(auth *Auth) *GeoLocationService

type GeoPoint

type GeoPoint struct {
	Latitude  int64 `xml:"latitudeInMicroDegrees"`
	Longitude int64 `xml:"longitudeInMicroDegrees"`
}

type ImageAd

type ImageAd struct {
	CommonAd
	Image             int64  `xml:"imageId"` //TODO should actually be Image object, not just an int
	Name              string `xml:"name"`
	AdToCopyImageFrom int64  `xml:"adToCopyImageFrom"`
}

ImageAd represents the equivalent object documented here https://developers.google.com/adwords/api/docs/reference/v201502/AdGroupAdService.ImageAd

func (ImageAd) CloneForTemplate

func (c ImageAd) CloneForTemplate(finalURLs []string, trackingURLTemplate *string) Ad

CloneForTemplate create a clone of an Ad, to recreate it for changing the tracking Url Template

func (ImageAd) MarshalXML

func (c ImageAd) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns unimplemented error as the structure does not match yet 100% of the field required by google api

type ImageUrl

type ImageUrl struct {
}

type KeywordCriterion

type KeywordCriterion struct {
	Type      string `xml:"xsi:type,attr,omitempty"`
	Id        int64  `xml:"id,omitempty"`
	Text      string `xml:"text,omitempty"`      // Text: up to 80 characters and ten words
	MatchType string `xml:"matchType,omitempty"` // MatchType:  "EXACT", "PHRASE", "BROAD"
}

func (KeywordCriterion) GetID

func (c KeywordCriterion) GetID() int64

type Label

type Label struct {
	Type   string `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"`
	Id     int64  `xml:"id,omitempty"`
	Name   string `xml:"name"`
	Status string `xml:"status,omitempty"`
}

Label represents a label.

func NewTextLabel

func NewTextLabel(name string) Label

NewTextLabel returns an new Label struct for creating a new TextLabel.

type LabelOperations

type LabelOperations map[string][]Label

LabelOperations is a map of operations to perform on Label's

type LabelService

type LabelService struct {
	Auth
}

func NewLabelService

func NewLabelService(auth *Auth) *LabelService

func (LabelService) Get

func (s LabelService) Get(selector Selector) (labels []Label, totalCount int64, err error)

Get returns an array of Label's and the total number of Label's matching the selector.

Example

labels, totalCount, err := labelService.Get(
  Selector{
    Fields: []string{"LabelId","LabelName","LabelStatus"},
    Predicates: []Predicate{
      {"LabelStatus", "EQUALS", []string{"ENABLED"}},
    },
  },
)

Selectable fields are

"LabelId", "LabelName", "LabelStatus"

filterable fields are

"LabelId", "LabelName", "LabelStatus"

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/LabelService#get

func (*LabelService) Mutate

func (s *LabelService) Mutate(labelOperations LabelOperations) (labels []Label, err error)

Mutate allows you to add, modify and remove labels, returning the modified labels.

Example

labels, err := labelService.Mutate(
  LabelOperations{
    "ADD": {
      NewTextLabel("Label1"),
      NewTextLabel("Label2"),
    },
    "SET": {
      modifiedLabel,
    },
    "REMOVE": {
      Label{Type:"TextLabel",Id:10},
    },
  },
)

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/LabelService#mutate

func (*LabelService) Query

func (s *LabelService) Query(query string) (labels []Label, totalCount int64, err error)

Query is not yet implemented

Relevant documentation

https://developers.google.com/adwords/api/docs/reference/v201409/LabelService#query

type LanguageCriterion

type LanguageCriterion struct {
	Type string `xml:"xsi:type,attr,omitempty"`
	Id   int64  `xml:"id,omitempty"`
	Code string `xml:"code,omitempty"`
	Name string `xml:"name,omitempty"`
}

func (LanguageCriterion) GetID

func (c LanguageCriterion) GetID() int64

type Location

type Location struct {
	Id              int64      `xml:"id,omitempty"`
	LocationName    string     `xml:"locationName,omitempty"`
	DisplayType     string     `xml:"displayType,omitempty"`
	TargetingStatus string     `xml:"targetingStatus,omitempty"`
	ParentLocations []Location `xml:"parentLocations,omitempty"`
}

LocationName: DisplayType: TargetingStatus: ACTIVE, OBSOLETE, PHASING_OUT ParentLocations:

func (Location) GetID

func (c Location) GetID() int64

type LocationCriterion

type LocationCriterion struct {
	Location      Location `xml:"location"`
	CanonicalName string   `xml:"canonicalName,omitempty"`
	Reach         string   `xml:"reach,omitempty"`
	Locale        string   `xml:"locale,omitempty"`
	SearchTerm    string   `xml:"searchTerm"`
}

type LocationCriterionService

type LocationCriterionService struct {
	Auth
}

func NewLocationCriterionService

func NewLocationCriterionService(auth *Auth) *LocationCriterionService

func (*LocationCriterionService) Get

func (s *LocationCriterionService) Get(selector Selector) (locationCriterions LocationCriterions, err error)

type LocationCriterions

type LocationCriterions []LocationCriterion

type ManagedCustomerService

type ManagedCustomerService struct {
	Auth
}

func NewManagedCustomerService

func NewManagedCustomerService(auth *Auth) *ManagedCustomerService

type Media

type Media struct {
	Type         string       `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"`
	Id           int64        `xml:"mediaId,omitempty"`
	MediaType    string       `xml:"type"` // "AUDIO", "DYNAMIC_IMAGE", "ICON", "IMAGE", "STANDARD_ICON", "VIDEO"
	ReferenceId  int64        `xml:"referenceId,omitempty"`
	Dimensions   []Dimensions `xml:"dimensions"`
	Urls         []ImageUrl   `xml:"urls"`
	MimeType     string       `xml:"mimeType,omitempty"` // "IMAGE_JPEG", "IMAGE_GIF", "IMAGE_PNG", "FLASH", "TEXT_HTML", "PDF", "MSWORD", "MSEXCEL", "RTF", "AUDIO_WAV", "AUDIO_MP3"
	SourceUrl    string       `xml:"sourceUrl,omitempty"`
	Name         string       `xml:"name"`
	FileSize     int64        `xml:"fileSize,omitempty"`   // File size in bytes
	CreationTime string       `xml:"createTime,omitempty"` // format is YYYY-MM-DD HH:MM:SS+TZ

	// Audio / Video
	DurationMillis   int64  `xml:"durationMillis,omitempty"`
	StreamingUrl     string `xml:"streamingUrl,omitempty"`
	ReadyToPlayOnWeb bool   `xml:"readyToPlayOnTheWeb,omitempty"`

	// Image
	Data string `xml:"data,omitempty"` // base64Binary encoded raw image data

	// Video
	IndustryStandardCommercialIdentifier string `xml:"industryStandardCommercialIdentifier,omitempty"`
	AdvertisingId                        string `xml:"advertisingId,omitempty"`
	YouTubeVideoIdString                 string `xml:"youTubeVideoIdString,omitempty"`
}

Media represents an audio, image or video file.

func NewAudio

func NewAudio(name, mediaType, mimeType string) (image Media)

func NewImage

func NewImage(name, mediaType, mimeType string, data []byte) (image Media)

func NewVideo

func NewVideo(mediaType string) (image Media)

type MediaService

type MediaService struct {
	Auth
}

func NewMediaService

func NewMediaService(auth *Auth) *MediaService

func (*MediaService) Get

func (s *MediaService) Get(selector Selector) (medias []Media, totalCount int64, err error)

func (*MediaService) Query

func (s *MediaService) Query(query string) (medias []Media, totalCount int64, err error)

func (*MediaService) Upload

func (s *MediaService) Upload(medias []Media) (uploadedMedias []Media, err error)
Example
// load image into []byte
imageUrl := "http://www.google.com/intl/en/adwords/select/images/samples/inline.jpg"
resp, err := http.Get(imageUrl)
if err != nil {
	panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)

// load credentials from
authConf, _ := NewCredentials(context.TODO())
ms := NewMediaService(&authConf.Auth)

images, err := ms.Upload([]Media{NewImage("image1", "IMAGE", "IMAGE_JPEG", body)})
if err != nil {
	panic(err)
}
fmt.Printf("%#v", images)
Output:

type MobileAd

type MobileAd struct {
	CommonAd
	Headline        string   `xml:"headline"`
	Description     string   `xml:"description"`
	MarkupLanguages []string `xml:"markupLanguages"`
	MobileCarriers  []string `xml:"mobileCarriers"`
	BusinessName    string   `xml:"businessName"`
	CountryCode     string   `xml:"countryCode"`
	PhoneNumber     string   `xml:"phoneNumber"`
}

MobileAd represents the equivalent object documented here https://developers.google.com/adwords/api/docs/reference/v201502/AdGroupAdService.MobileAd

func (MobileAd) CloneForTemplate

func (c MobileAd) CloneForTemplate(finalURLs []string, trackingURLTemplate *string) Ad

CloneForTemplate create a clone of an Ad, to recreate it for changing the tracking Url Template

type MobileAppCategoryCriterion

type MobileAppCategoryCriterion struct {
	Type                string `xml:"xsi:type,attr,omitempty"`
	Id                  int64  `xml:"id,omitempty"`
	MobileAppCategoryId int64  `xml:"mobileAppCategoryId"`
	DisplayName         string `xml:"displayName,omitempty"`
}

MobileAppCategoryId:

https://developers.google.com/adwords/api/docs/appendix/mobileappcategories

DisplayName:

func (MobileAppCategoryCriterion) GetID

type MobileApplicationCriterion

type MobileApplicationCriterion struct {
	Type        string `xml:"xsi:type,attr,omitempty"`
	Id          int64  `xml:"id,omitempty"`
	AppId       string `xml:"appId"`
	DisplayName string `xml:"displayName,omitempty"`
}

AppId: "{platform}-{platform_native_id}" DisplayName:

func (MobileApplicationCriterion) GetID

type MobileDeviceCriterion

type MobileDeviceCriterion struct {
	Type                string `xml:"xsi:type,attr,omitempty"`
	Id                  int64  `xml:"id,omitempty"`
	DeviceName          string `xml:"deviceName,omitempty"`
	ManufacturerName    string `xml:"manufacturerName,omitempty"`
	DeviceType          string `xml:"deviceType,omitempty"`
	OperatingSystemName string `xml:"operatingSystemName,omitempty"`
}

DeviceName: ManufacturerName: DeviceType: DEVICE_TYPE_MOBILE, DEVICE_TYPE_TABLET OperatingSystemName:

func (MobileDeviceCriterion) GetID

func (c MobileDeviceCriterion) GetID() int64

type MutateJobService

type MutateJobService struct {
	Auth
}

func NewMutateJobService

func NewMutateJobService(auth *Auth) *MutateJobService

type NegativeAdGroupCriterion

type NegativeAdGroupCriterion struct {
	AdGroupId int64     `xml:"adGroupId"`
	Criterion Criterion `xml:"criterion"`
}

func (NegativeAdGroupCriterion) MarshalXML

func (nagc NegativeAdGroupCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*NegativeAdGroupCriterion) UnmarshalXML

func (nagc *NegativeAdGroupCriterion) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error

type NegativeCampaignCriterion

type NegativeCampaignCriterion struct {
	CampaignId  int64     `xml:"campaignId"`
	Criterion   Criterion `xml:"criterion"`
	BidModifier float64   `xml:"bidModifier,omitempty"`
	Errors      []error   `xml:"-"`
}

func (NegativeCampaignCriterion) MarshalXML

func (ncc NegativeCampaignCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type NetworkSetting

type NetworkSetting struct {
	TargetGoogleSearch         bool `xml:"targetGoogleSearch"`
	TargetSearchNetwork        bool `xml:"targetSearchNetwork"`
	TargetContentNetwork       bool `xml:"targetContentNetwork"`
	TargetPartnerSearchNetwork bool `xml:"targetPartnerSearchNetwork"`
}

type NotEmptyError

type NotEmptyError struct {
	FieldPath   string `xml:"fieldPath"`
	Trigger     string `xml:"trigger"`
	ErrorString string `xml:"errorString"`
	Reason      string `xml:"reason"`
}

type NumberRuleItem

type NumberRuleItem struct {
	Key   string `xml:"key>name"`
	Op    string `xml:"op"` // "UNKNOWN", "GREATER_THAN", "GREATER_THAN_OR_EQUAL", "EQUALS", "NOT_EQUAL", "LESS_THAN", "LESS_THAN_OR_EQUAL"
	Value int64  `xml:"value"`
}

type OfflineConversionService

type OfflineConversionService struct {
	Auth
}

func NewOfflineConversionService

func NewOfflineConversionService(auth *Auth) *OfflineConversionService

type OperatingSystemVersionCriterion

type OperatingSystemVersionCriterion struct {
	Type           string `xml:"xsi:type,attr,omitempty"`
	Id             int64  `xml:"id,omitempty"`
	Name           string `xml:"name,omitempty"`
	OsMajorVersion int64  `xml:"osMajorVersion,omitempty"`
	OsMinorVersion int64  `xml:"osMinorVersion,omitempty"`
	OperatorType   string `xml:"operatorType,omitempty"`
}

Name: OsMajorVersion: OsMinorVersion: OperatorType: GREATER_THAN_EQUAL_TO, EQUAL_TO, UNKNOWN

func (OperatingSystemVersionCriterion) GetID

type OperationError

type OperationError struct {
	Code      int64  `xml:"OperationError>Code"`
	Details   string `xml:"OperationError>Details"`
	ErrorCode string `xml:"OperationError>ErrorCode"`
	Message   string `xml:"OperationError>Message"`
}

type OrderBy

type OrderBy struct {
	Field     string `xml:"field"`
	SortOrder string `xml:"sortOrder"`
}

type Paging

type Paging struct {
	Offset int64 `xml:"startIndex"`
	Limit  int64 `xml:"numberResults"`
}

type PlacementCriterion

type PlacementCriterion struct {
	Type string `xml:"xsi:type,attr,omitempty"`
	Id   int64  `xml:"id,omitempty"`
	Url  string `xml:"url"`
}

Url:

func (PlacementCriterion) GetID

func (c PlacementCriterion) GetID() int64

type PlatformCriterion

type PlatformCriterion struct {
	Type         string `xml:"xsi:type,attr,omitempty"`
	Id           int64  `xml:"id,omitempty"`
	PlatformName string `xml:"platformName,omitempty"`
}

PlatformId:

Desktop	30000
HighEndMobile	30001
Tablet	30002

func (PlatformCriterion) GetID

func (c PlatformCriterion) GetID() int64

type Predicate

type Predicate struct {
	Field    string   `xml:"field"`
	Operator string   `xml:"operator"`
	Values   []string `xml:"values"`
}

type ProductCondition

type ProductCondition struct {
	Argument string `xml:"argument"`
	Operand  string `xml:"operand"`
}

Argument: Operand: id, product_type, brand, adwords_grouping, condition, adwords_labels

type ProductCriterion

type ProductCriterion struct {
	Type       string             `xml:"xsi:type,attr,omitempty"`
	Id         int64              `xml:"id,omitempty"`
	Conditions []ProductCondition `xml:"conditions,omitempty"`
	Text       string             `xml:"text,omitempty"`
}

func (ProductCriterion) GetID

func (c ProductCriterion) GetID() int64

type ProximityCriterion

type ProximityCriterion struct {
	Type                string   `xml:"xsi:type,attr,omitempty"`
	Id                  int64    `xml:"id,omitempty"`
	GeoPoint            GeoPoint `xml:"geoPoint"`
	RadiusDistanceUnits string   `xml:"radiusDistanceUnits"`
	RadiusInUnits       float64  `xml:"radiusInUnits"`
	Address             Address  `xml:"address"`
}

RadiusDistanceUnits: KILOMETERS, MILES RadiusUnits:

func (ProximityCriterion) GetID

func (c ProximityCriterion) GetID() int64

type QualityInfo

type QualityInfo struct {
	IsKeywordAdRelevanceAcceptable bool  `xml:"isKeywordAdRelevanceAcceptable,omitempty"`
	IsLandingPageQualityAcceptable bool  `xml:"isLandingPageQualityAcceptable,omitempty"`
	IsLandingPageLatencyAcceptable bool  `xml:"isLandingPageLatencyAcceptable,omitempty"`
	QualityScore                   int64 `xml:"QualityScore,omitempty"`
}

type RateExceededError

type RateExceededError struct {
	RateName          string `xml:"rateName"`  // For example OperationsByMinute
	RateScope         string `xml:"rateScope"` // ACCOUNT or DEVELOPER
	ErrorString       string `xml:"errorString"`
	Reason            string `xml:"reason"`
	RetryAfterSeconds uint   `xml:"retryAfterSeconds"` // Try again in...
}

if you exceed the quota given by google

type ReportDefinitionService

type ReportDefinitionService struct {
	Auth
}

func NewReportDefinitionService

func NewReportDefinitionService(auth *Auth) *ReportDefinitionService

type Rule

type Rule struct {
	Groups []RuleItemGroup `xml:"groups"`
}

type RuleItemGroup

type RuleItemGroup struct {
	Items []interface{} `xml:"items"`
}

type Selector

type Selector struct {
	XMLName    xml.Name
	Fields     []string    `xml:"fields"`
	Predicates []Predicate `xml:"predicates"`
	DateRange  *DateRange  `xml:"dateRange,omitempty"`
	Ordering   []OrderBy   `xml:"ordering"`
	Paging     *Paging     `xml:"paging,omitempty"`
}

type ServiceUrl

type ServiceUrl struct {
	Url  string
	Name string
}

func (ServiceUrl) String

func (s ServiceUrl) String() string

type SharedCriterionService

type SharedCriterionService struct {
	Auth
}

func NewSharedCriterionService

func NewSharedCriterionService(auth *Auth) *SharedCriterionService

type SharedSetService

type SharedSetService struct {
	Auth
}

func NewSharedSetService

func NewSharedSetService(auth *Auth) *SharedSetService

type StringRuleItem

type StringRuleItem struct {
	Key   string `xml:"key>name"`
	Op    string `xml:"op"` // "UNKNOWN", "CONTAINS", "EQUALS", "STARTS_WITH", "ENDS_WITH", "NOT_EQUAL", "NOT_CONTAIN", "NOT_START_WITH", "NOT_END_WITH"
	Value string `xml:"string"`
}

type TargetError

type TargetError struct {
	FieldPath   string `xml:"fieldPath"`
	Trigger     string `xml:"trigger"`
	ErrorString string `xml:"errorString"`
	Reason      string `xml:"reason"`
}

type TargetIdeaService

type TargetIdeaService struct {
	Auth
}

func NewTargetIdeaService

func NewTargetIdeaService(auth *Auth) *TargetIdeaService

type TargetSettingDetail

type TargetSettingDetail struct {
	CriterionTypeGroup string `xml:"criterionTypeGroup"`
	TargetAll          bool   `xml:"targetAll"`
}

type TemplateAd

type TemplateAd struct {
	CommonAd
	TemplateID       int64             `xml:"templateId"`
	AdUnionID        int64             `xml:"adUnionId"`
	TemplateElements []TemplateElement `xml:"templateElements"`
	Dimensions       []Dimensions      `xml:"dimensions"`
	Name             string            `xml:"name"`
	Duration         int64             `xml:"duration"`
	// contains filtered or unexported fields
}

TemplateAd represents the equivalent object documented here https://developers.google.com/adwords/api/docs/reference/v201502/AdGroupAdService.TemplateAd

func (TemplateAd) CloneForTemplate

func (c TemplateAd) CloneForTemplate(finalURLs []string, trackingURLTemplate *string) Ad

CloneForTemplate create a clone of an Ad, to recreate it for changing the tracking Url Template

func (TemplateAd) MarshalXML

func (c TemplateAd) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns unimplemented error as the structure does not match yet 100% of the field required by google api

type TemplateElement

type TemplateElement struct {
	UniqueName string                 `xml:"uniqueName"`
	Fields     []TemplateElementField `xml:"fields"`
}

type TemplateElementField

type TemplateElementField struct {
	Name       string `xml:"name"`
	Type       string `xml:"type"`
	FieldText  string `xml:"fieldText"`
	FieldMedia string `xml:"fieldMedia"`
}

type TextAd

type TextAd struct {
	CommonAd
	Headline     string `xml:"headline"`
	Description1 string `xml:"description1"`
	Description2 string `xml:"description2"`
}

TextAd represents the TextAd object as documented here https://developers.google.com/adwords/api/docs/reference/v201506/AdGroupAdService.TextAd

func (TextAd) CloneForTemplate

func (c TextAd) CloneForTemplate(finalURLs []string, trackingURLTemplate *string) Ad

CloneForTemplate create a clone of an Ad, to recreate it for changing the tracking Url Template

type TrafficEstimatorService

type TrafficEstimatorService struct {
	Auth
}

func NewTrafficEstimatorService

func NewTrafficEstimatorService(auth *Auth) *TrafficEstimatorService

type UnknownError

type UnknownError struct {
	FieldPath   string `xml:"fieldPath"`
	Trigger     string `xml:"trigger"`
	ErrorString string `xml:"errorString"`
	Reason      string `xml:"reason"`
}

type UserInterestCriterion

type UserInterestCriterion struct {
	Type string `xml:"xsi:type,attr,omitempty"`
	Id   int64  `xml:"userInterestId,omitempty"`
	Name string `xml:"userInterestName"`
}

func (UserInterestCriterion) GetID

func (c UserInterestCriterion) GetID() int64

type UserList

type UserList struct {
	Id                    int64   `xml:"id"`
	Readonly              *bool   `xml:"isReadOnly"`
	Name                  string  `xml:"name"`
	Description           string  `xml:"description"`
	Status                string  `xml:"status"` // membership status "OPEN", "CLOSED"
	IntegrationCode       string  `xml:"integrationCode"`
	AccessReason          string  `xml:"accessReason"`          // account access resson "OWNER", "SHARED", "LICENSED", "SUBSCRIBED"
	AccountUserListStatus string  `xml:"accountUserListStatus"` // if share is still active "ACTIVE", "INACTIVE"
	MembershipLifeSpan    int64   `xml:"membershipLifeSpan"`    // number of days cookie stays on list
	Size                  *int64  `xml:"size,omitempty"`
	SizeRange             *string `xml:"sizeRange,omitempty"`          // size range "LESS_THEN_FIVE_HUNDRED","LESS_THAN_ONE_THOUSAND", "ONE_THOUSAND_TO_TEN_THOUSAND","TEN_THOUSAND_TO_FIFTY_THOUSAND","FIFTY_THOUSAND_TO_ONE_HUNDRED_THOUSAND","ONE_HUNDRED_THOUSAND_TO_THREE_HUNDRED_THOUSAND","THREE_HUNDRED_THOUSAND_TO_FIVE_HUNDRED_THOUSAND","FIVE_HUNDRED_THOUSAND_TO_ONE_MILLION","ONE_MILLION_TO_TWO_MILLION","TWO_MILLION_TO_THREE_MILLION","THREE_MILLION_TO_FIVE_MILLION","FIVE_MILLION_TO_TEN_MILLION","TEN_MILLION_TO_TWENTY_MILLION","TWENTY_MILLION_TO_THIRTY_MILLION","THIRTY_MILLION_TO_FIFTY_MILLION","OVER_FIFTY_MILLION"
	SizeForSearch         *int64  `xml:"sizeForSearch,omitempty"`      // estimated number of google.com users in this group
	SizeRangeForSearch    *string `xml:"sizeRangeForSearch,omitempty"` // same values as size range but for search
	ListType              *string `xml:"sizeType,omitempty"`           // one of "UNKNOWN", "REMARKETING", "LOGICAL", "EXTERNAL_REMARKETING", "RULE_BASED", "SIMILAR"

	// LogicalUserList
	LogicalRules *[]UserListLogicalRule `xml:"rules,omitempty"`

	// BasicUserList
	ConversionTypes *[]UserListConversionType `xml:"conversionTypes"`

	// RuleUserList
	Rule      *Rule   `xml:"rule,omitempty"`
	StartDate *string `xml:"startDate,omitempty"`
	EndDate   *string `xml:"endDate,omitempty"`

	// SimilarUserList
	SeedUserListId          *int64  `xml:"seedUserListId,omitempty"`
	SeedUserListName        *string `xml:"seedUserListName,omitempty"`
	SeedUserListDescription *string `xml:"seedUserListDescription,omitempty"`
	SeedUserListStatus      *string `xml:"seedUserListStatus,omitempty"`
	SeedListSize            *int64  `xml:"seedListSize,omitempty"`
}

func NewBasicUserList

func NewBasicUserList(name, description, status, integrationCode string, membershipLifeSpan int64, conversionTypes []UserListConversionType) (adwordsUserList UserList)

func NewDateSpecificRuleUserList

func NewDateSpecificRuleUserList(name, description, status, integrationCode string, membershipLifeSpan int64, rule Rule, startDate, endDate string) (adwordsUserList UserList)

func NewExpressionRuleUserList

func NewExpressionRuleUserList(name, description, status, integrationCode string, membershipLifeSpan int64, rule Rule) (adwordsUserList UserList)

func NewLogicalUserList

func NewLogicalUserList(name, description, status, integrationCode string, membershipLifeSpan int64, logicalRules []UserListLogicalRule) (adwordsUserList UserList)

func NewSimilarUserList

func NewSimilarUserList(name, description, status, integrationCode string, membershipLifeSpan int64) (adwordsUserList UserList)

type UserListConversionType

type UserListConversionType struct {
	Id       *int64
	Name     string
	Category *string `xml:"category"` // "BOOMERANG_EVENT", "OTHER"
}

type UserListCriterion

type UserListCriterion struct {
	Type                     string `xml:"xsi:type,attr,omitempty"`
	Id                       int64  `xml:"id,omitempty"`
	UserListId               int64  `xml:"userListId"`
	UserListName             string `xml:"userListName"`
	UserListMembershipStatus string `xml:"userListMembershipStatus"`
}

func (UserListCriterion) GetID

func (c UserListCriterion) GetID() int64

type UserListLogicalRule

type UserListLogicalRule struct {
	Operator     string     `xml:"operator"` // "ALL", "ANY", "NONE", "UNKNOWN"
	RuleOperands []UserList `xml:"ruleOperands"`
}

type UserListOperations

type UserListOperations struct {
}

type VerticalCriterion

type VerticalCriterion struct {
	Type     string   `xml:"xsi:type,attr,omitempty"`
	Id       int64    `xml:"verticalId,omitempty"`
	ParentId int64    `xml:"verticalParentId"`
	Path     []string `xml:"path"`
}

func (VerticalCriterion) GetID

func (c VerticalCriterion) GetID() int64

type WebpageCondition

type WebpageCondition struct {
	Operand  string `xml:"operand"`
	Argument string `xml:"argument"`
}

type WebpageCriterion

type WebpageCriterion struct {
	Type             string           `xml:"xsi:type,attr,omitempty"`
	Id               int64            `xml:"id,omitempty"`
	Parameter        WebpageParameter `xml:"parameter"`
	CriteriaCoverage float64          `xml:"criteriaCoverage"`
	CriteriaSamples  []string         `xml:"criteriaSamples"`
}

func (WebpageCriterion) GetID

func (c WebpageCriterion) GetID() int64

type WebpageParameter

type WebpageParameter struct {
	CriterionName string             `xml:"criterionName"`
	Conditions    []WebpageCondition `xml:"conditions"`
}

Directories

Path Synopsis
setup_oauth2 is a tool for creating a gads configuration file config.json from the installed application credential stored in credentials.json.
setup_oauth2 is a tool for creating a gads configuration file config.json from the installed application credential stored in credentials.json.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL