If this were not true??”if the market were completely random
??”we couldn??™t make any intelligent reporting in any event.
Note that the helper methods are automatically available to your controller and to
your view, so they can automatically be used in your view. The format_currency_helper
(Listing 13-4) looks like this:
def format_google_currency(currency_value)
"#{'%0.2f' % (currency_value/10000.0) } cents"
end
As you can see, the helper divides by 10,000 and then formats the value with two
decimal points, followed by the word ???cents.??? If you wanted to display a dollar format
instead, you could use a helper like this:
def format_google_currency(currency_value)
"#{'$%0.2f' % (currency_value/1000000.0) } "
end
This alternate helper displays values like $0.23 instead of 23 cents. It divides by
1,000,000 instead of 10,000, since the units of currency in the XML files are millionths
of a dollar, which is equivalent to ten thousandths of a cent.
The remainder of the code in report.rhtml (Listing 13-6) just prints out a few variables
from your controller that relate to the entire campaign:
Summary
Goal Clicks |
<%=@target_clicks%> |
|---|
Estimated Available Clicks |
<%=@estimated_clicks%> |
|---|
Estimated Cost Per Click (CPC) |
<%=format_google_currency(@avg_cost_per_click )%> |
CHAPTER 13 n TRACKING YOUR ADS WITH GOOGLE ADWORDS 283
|---|
Note that if you so desired, you could use just one table by replacing this following
chunk:
Summary