npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fnet/gpt-slot-ext

v0.1.5

Published

This project provides a straightforward method to create and manage ad slots for Google Publisher Tags (GPT). It is designed to be a minimalistic approach to handling ad configurations, making it easier for developers to implement ad units within web appl

Downloads

20

Readme

@fnet/gpt-slot-ext

This project provides a straightforward method to create and manage ad slots for Google Publisher Tags (GPT). It is designed to be a minimalistic approach to handling ad configurations, making it easier for developers to implement ad units within web applications.

How It Works

The project operates by allowing users to input ad configuration details such as the ad unit path, sizes, and targeting data. It then returns these details in a structured format. This enables developers to efficiently retrieve and incorporate ad slot configurations into their web applications with minimal setup.

Key Features

  • Ad Unit Configuration: Input and manage the adUnitPath, which specifies the unique path for the ad slot.
  • Size Management: Define the ad slot sizes to ensure they fit within your web application's layout.
  • Targeting Options: Set targeting parameters to control which ads are displayed based on user attributes or behavior.

Conclusion

@fnet/gpt-slot-ext provides a simple and clear approach to managing ad slot configurations for GPT. By focusing on the basic yet essential aspects of ad setup, it offers a streamlined solution for developers looking to integrate advertising into their platforms without complication.

Developer Guide for @fnet/gpt-slot-ext

Overview

The @fnet/gpt-slot-ext library is designed to simplify the management of ad slots in web applications. It allows developers to define ad units with specific configurations and retrieve these configurations easily for integration with advertising services. The library focuses on providing a straightforward API to handle ad unit paths, sizes, and targeting parameters efficiently.

Installation

You can install the @fnet/gpt-slot-ext library using npm or yarn. Follow the instructions below to include it in your project:

Using npm

npm install @fnet/gpt-slot-ext

Using yarn

yarn add @fnet/gpt-slot-ext

Usage

To utilize the @fnet/gpt-slot-ext library, you need to import the default export and use the provided functionalities to manage your ad slots. Here’s a basic example of how to define and retrieve an ad slot configuration:

import gptSlotExt from '@fnet/gpt-slot-ext';

const setupAdSlot = async () => {
  const adConfig = {
    adUnitPath: '/1234567/homepage',
    sizes: [[300, 250], [728, 90]],
    targeting: { interests: 'sports' },
  };

  const adSlot = await gptSlotExt(adConfig);
  const slotDetails = await adSlot.getSlot();

  console.log(slotDetails);
  // Output should look like: 
  // {
  //   adUnitPath: '/1234567/homepage',
  //   sizes: [[300, 250], [728, 90]],
  //   targeting: { interests: 'sports' }
  // }
};

setupAdSlot();

Examples

Here are some more examples demonstrating the core functionality of the library:

Example 1: Basic Ad Slot Configuration

import gptSlotExt from '@fnet/gpt-slot-ext';

const initAdSlot = async () => {
  const config = {
    adUnitPath: '/9876543/category',
    sizes: [[160, 600], [300, 600]],
    targeting: { audience: 'tech-savvy' },
  };

  const slot = await gptSlotExt(config);
  const details = await slot.getSlot();

  console.log(details);
};

initAdSlot();

Example 2: Multiple Sizes and Multiple Targeting Keys

import gptSlotExt from '@fnet/gpt-slot-ext';

const configureAdSlot = async () => {
  const multiConfig = {
    adUnitPath: '/3456789/articles',
    sizes: [[320, 50], [300, 250], [728, 90]],
    targeting: { interests: 'gaming', ageGroup: '18-24' },
  };

  const slot = await gptSlotExt(multiConfig);
  const adDetails = await slot.getSlot();

  console.log(adDetails);
};

configureAdSlot();

Acknowledgement

This library was developed by Fnet and is maintained by its contributors. We appreciate any feedback or contributions to improve this project.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  adUnitPath:
    type: string
    description: Path of the ad unit
  sizes:
    type: array
    items:
      type: array
      items:
        type: integer
    description: Sizes for the ad unit as an array of integer arrays
  targeting:
    type: object
    additionalProperties:
      type: string
    description: Targeting parameters as key-value pairs
required:
  - adUnitPath
  - sizes
  - targeting