0.0
No commit activity in last 3 years
No release in over 3 years
Google provides page-level ads api (javascript) to show ads on mobile; adsense_mobile gem support google page-level ads api.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 5.0
~> 10.0
 Project Readme

Gem Version

AdsenseMobile

It is a helper to create the google adsense page-level ads tag in rails. Instead of using vanilla javascript for managing google adsense, it would be easier and hassle free to use adsense_mobile_tag tag to achieve the same.

Installation

Add below line to your application's Gemfile:

gem 'adsense_mobile'

And then execute:

$ bundle

Or install it yourself as:

$ gem install adsense_mobile

Usage

Basic page-level ads

<%= adsense_mobile_tag client: 'ca-pub-269xxxxxxxxxx' %>

Currently, the Page-level ads family includes the Anchor/overlay and Vignette ad formats, see the Google Documentation Guide.

Place below tag in the <head> section (or at the top of the <body>) of the pages where you want to show the ads.

  1. For Anchor/overlay ads

<%= adsense_mobile_tag client: 'ca-pub-269xxxxxxxxxx', overlays: '89xxxxxxx' %>

  1. For Vignette ads

<%= adsense_mobile_tag client: 'ca-pub-269xxxxxxxxxx', vignettes: '70xxxxxxx' %>

  1. For Anchor and Vignette ads

<%= adsense_mobile_tag client: 'ca-pub-269xxxxxxxxxx', vignettes: '70xxxxxxx', overlays: '89xxxxxxx' %>

It automatically maps required parameter according to google adsence API.

     client: 'ca-pub-269xxxxxxxxxx'    google_ad_client: 'ca-pub-269xxxxxxxxxx'
   overlays: '89xxxxxxx'                       overlays: { google_ad_channel: '89xxxxxxx' }
  vignettes: '70xxxxxxx'                      vignettes: { google_ad_channel: '70xxxxxxx' }

NOTE: If environment is not production, it'll show passed parameters in span tag.

{:client=>"ca-pub-2691264448085943", :vignettes=>"7013276711", :overlays=>"7013276711"}

To test page-level ads on production or on a mobile device, visit your page (website) and add #googleads to the end of the URL and reload the page.

If parameters are invalid, it shows error massage in span tag.

You are passing wrong parameters, please check documentation.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/adsense_mobile. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.