Git Product home page Git Product logo

react-google-publisher-tag's Introduction

React Google Publisher Tag

Motivation

I needed to show adsense via google publisher tag in my react isomorphic application. Please read carefully (AdSense terms)[https://support.google.com/adsense/answer/48182?hl=en]. You are using this module on your own risk.

Install

npm install react-google-publisher-tag

Features

  • Automatically show AD and fit the size
  • Automatically load google script
  • Support for mobile (you can show different size for mobile users)
  • Support for isomorphic applications
  • Support for responsible layout

Usage

  • Go to https://www.google.com/dfp and create a new Ad unit. (tab Inventory)
  • Add sizes: 120x240, 120x600, 125x125, 160x600, 180x150, 200x200, 234x60, 240x400, 250x250, 300x100, 300x250, 300x600, 320x50, 336x280, 468x60, 728x90, 970x90
  • Use ad code as path in the react component

App.jsx

Application part (load google analytics script to your webpage on the client side). ReactGAnalytics has parameter ID (use your own ID)

var React = require('react');
var AD = require('react-google-publisher-tag');

var App = module.exports = React.createClass({
  render: function() {
    return (
      <div id="application">
        <AD path="/network-code/ad-code" />
        <RouteHandler />
      </div>
    );
  }
});

Parameters

Name Type Required Default
path String true
responsive Boolean true true
format String true HORIZONTAL
canBeLower Boolean true true
dimensions Array false
sizeMap Array false
minWindowWidth Integer false -1
maxWindowWidth Integer false -1
className String false

Path

Path is only one required parameter. The format is: /network-code/ad-code

Example:

/22222222/myad

Network code

You can find your network code in the Admin tab (Google DFP). This unique code is included in DFP tags to identify the network, ensuring that DFP looks in the correct network for line items that are targeted to a particular ad unit. It's displayed here to help you identify which network is associated with any DFP tags you have on your site.

Ad code

You can find your ad code when you click on your ad in the Google DFP (Inventary tab) Identifies the ad unit in the associated ad tag. Ad unit codes can be up to 100 characters in length. Only letters, numbers, underscores, hyphens, periods, asterisks, forward slashes, backslashes, exclamations, left angle brackets, colons and parentheses are allowed. Each code must be unique; you can't reuse codes you've used before. Once you've created the ad unit, you can't change the code.

Formats

It will setup ad size automatically for this component:

  • HORIZONTAL [[970, 90], [728, 90], [468, 60], [234, 60]]
  • RECTANGLE [[336, 280], [300, 250], [250, 250], [200, 200], [180, 150], [125, 125]]
  • VERTICAL [[300, 600], [160, 600], [120, 600], [120, 240]]
  • MOBILE: [[320, 50]],
  • 300x600: [[300, 600], [160, 600]]
  • 336x280: [[336, 280], [300, 250]]
  • 728x90: [[728, 90], [468, 60]]
  • 970x90: [[970, 90], [728, 90], [468, 60]]

Can be lower

You can allow lower ad size automatically. (Default: true)

Credits

Zlatko Fedor

License

The MIT License (MIT)

Copyright (c) 2015 Zlatko Fedor [email protected]

react-google-publisher-tag's People

Contributors

jaehanley avatar seeden avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.