Sem4r version 0.0.7 released

Released version 0.0.7 on gemcutter.

  • added simple command line interface. With this command interfase it is possible to
    list clients, reports, keywords, etc on the adwords accounts.
  • added support for AdGroup Bids and AdGroup Criterion Bids,
    without them this library is useless!

Sem4r version 0.0.6 released

Released version 0.0.6 on gemcutter.

  • added lot of test, according to caliper code:test ratio is 0.5. Low
    but it is improving.
  • added initial support for BulkMutateJob.

Using Ad Parameters

In the site of v2009 Hack Day there is a presentation
about using ad parameters.

The ad parameters “allows you to change ad parameter text without having
to modify or create a new ad”1. I use the same example of presentation.

We can refence parameters in text ad simple adding it between “{}”:

text_ad do
  headline      "Save on Rossignol skis"
  description1  "Great deal on Rissignol starting at"
  description2  "{param1:lowprices}! Save {param2:big time}!"
  url           "http://skideals.com"
  display_url   "www.SkiDeals.com"
end

We can associate parameter to a keyword in this way:

keyword do
  text       "ski deal rossignol"
  match      "BROAD"

  ad_param do
    index 1
    text  "$279"
  end

  ad_param do
    index 2
    text  "20%"
  end
end

So to create an adgroup with parameters:

adgroup do
  name "Skis for sales"

  text_ad do
    headline      "Save on Rossignol skis"
    description1  "Great deal on Rissignol starting at"
    description2  "{param1:lowprices}! Save {param2:big time}!"
    url           "http://skideals.com"
    display_url   "www.SkiDeals.com"
  end

  keyword do
    text       "ski deal rossignol"
    match      "BROAD"

    ad_param do
      index 1
      text  "$279"
    end

    ad_param do
      index 2
      text  "20%"
    end
  end
end

Putting all together:

 1 require 'rubygems'
 2 require 'sem4r'
 3 include Sem4r
 4 
 5 adwords = Adwords.sandbox(
 6   :email => "<myaccount>@gmail.com",
 7   :password => "secret",
 8   :developer_token => "<myaccount>@gmail.com++EUR")
 9 
10 client_account = adwords.account.client_accounts.first
11 
12 campaign = client_account.campaign do
13   name "Skis"
14 
15   adgroup do
16     name "Skis for sales"
17 
18     text_ad do
19       headline      "Save on Rossignol skis"
20       description1  "Great deal on Rissignol starting at"
21       description2  "{param1:lowprices}! Save {param2:big time}!"
22       url           "http://skideals.com"
23       display_url   "www.SkiDeals.com"
24     end
25 
26     keyword do
27       text       "ski deal rossignol"
28       match      "BROAD"
29 
30       ad_param do
31         index 1
32         text  "$279"
33       end
34 
35       ad_param do
36         index 2
37         text  "20%"
38       end
39     end
40   end
41 end
42 
43 campaign.adgroups(true).each do |adgroup|
44   adgroup.p_ad_params
45 end

You can find the example code (eventually updated) on github

1 presentation

Constants scope are different from Ruby 1.8.7 and Ruby 1.9.1

The following code works with ruby 1.9.1 but doesn’t work with ruby 1.8.7:

class A
 C = "c"
end

A.new.instance_eval do
 puts C
end

If you try to execute the previous code with ruby 1.8.7, you will obtain:

2010-02-06-constants-scope.rb:7: uninitialized constant C (NameError)
	from 2010-02-06-constants-scope.rb:6:in `instance_eval'
	from 2010-02-06-constants-scope.rb:6

C is not recognized as constant in 1.8.7. Ruby 1.8.7 try to resolve C is in
Object class, and doesn’t found it.
Ruby 1.9.1 try to resolve C in the A class so doesn’t fail!

Sem4r use heavily symbols. For example to specify the match type in keyword:

keyword do
   match_type BROAD
end

The previous code work in ruby 1.9.1. In ruby 1.8.7 you must use:

keyword do
   match_type "BROAD"
end

Sem4r version 0.0.5 released

Released version 0.0.5 on gemcutter.

  • Removed application token, see post on official Adwords Api Blog
  • Fixed bug on Account#targeting_idea method.