Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

goopubtag

IainMcHugh1kMIT0.3.0TypeScript support: included

React library for Google Publisher tag

react, goopubtag, google publisher tag, gpt, dfp, double click for publishers, ad manager, ads, advertising

readme

Goopubtag

badge

Goopubtag is a modern solution for Google Publisher tag in React applications. It was heavily inspired by the widely used react-dfp package, and aims to provide a similar DX but with some improvements:

  • Functional approach (with hooks) 🪝
  • Type safety with typescript 🎉
  • Ease of use with debug mode 🛠️
  • Support for most recent GPT implementations 🚀

To get started, head over to the documentation site.

Installation

At the route of your application, in your terminal run:

npm install goopubtag # or yarn, pnpm

Usage

After installation is complete, you can start using goopubtag in your application:

import { GPTProvider, GPTSlot } from 'goopubtag';

const Component = () => {
  return (
    <div>
      <GPTProvider networkId={123456}>
        {/** .. */}
        <GPTSlot slotId="your-slot-id">
      </GPTProvider>
    </div>
  );
}

changelog

goopubtag

0.3.0

Minor Changes

  • 3b9657f: Fixed out of page implementation, breaking changes:

    • outOfPage prop no longer exists on GPTSlot
    • outOfPage prop on GPTProvider has changed

    • updated readme

    • updated tests
    • added examples for side rail ads
    • fixed console error "div element is already associated with another slot"

0.2.3

Patch Changes

  • 941b237: Remove isLoading state, init googletag and cmd as recommended

0.2.2

Patch Changes

  • 6bc0420: Enable single request

0.2.1

Patch Changes

  • d5df73a: This fixes a bug where the size mapping for responsive ads was not being defined properly

0.2.0

Minor Changes

  • a89e501: - Built using tsup minify flag, reducing build size

0.1.0

Minor Changes

  • d68f04a: - Add the ability to lazy load units
    • Reduce re-renders with memoization
    • Fix bug in event listeners

0.0.6

Patch Changes

  • 5ab382a: Updating all packages

0.0.5

Patch Changes

  • Fix peer dependencies bug

0.0.4

Patch Changes

  • This change involves:

    • An internal directory restructure
    • Generic Type for Page level targeting in GPTProvider
    • Generic Type for Unit level targeting and slotId in GPTSlot
    • Generic Types for targeting methods in useGPT
    • Comprehensive commenting for better intellisense