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

@bygd/opus-gpt-slot-hl

v0.1.24

Published

## Introduction

Downloads

19

Readme

@bygd/opus-gpt-slot-hl

Introduction

The @bygd/opus-gpt-slot-hl project provides a utility for configuring and managing advertising slots on web pages. It simplifies the task of setting up ad slots by automatically fetching and applying configuration details, making it easier for developers to prepare their web pages for ad delivery.

How It Works

This project functions by accessing configuration data specific to your page and ad requirements. By interfacing with external configuration tools, it retrieves necessary data about ad slots such as targeting criteria, sizes, and paths. Once this data is obtained, it processes and prepares ad units for your use, allowing for seamless integration with advertisement delivery networks.

Key Features

  • Automated Configuration Retrieval: Automatically gathers required configuration from a specified source, reducing manual setup.
  • Ad Slot Management: Facilitates creating ad slots with appropriate sizes and path specifications.
  • Customizable Targeting: Allows additional targeting specifications to be added or modified, offering flexibility in how ads are targeted.

Conclusion

In essence, @bygd/opus-gpt-slot-hl aids in the efficient setup and management of ad slots on web pages by leveraging pre-configured settings and providing the necessary data structure required to implement ads. It focuses on simplifying the process for web developers, allowing them to concentrate more on content development and user experience.

Developer Guide for @bygd/opus-gpt-slot-hl

Overview

The @bygd/opus-gpt-slot-hl library is designed to streamline the process of configuring ad slots with Google's Publisher Tags (GPT). By utilizing this library, developers can easily configure and generate ad unit paths, sizes, and targeting parameters for ad slots. The core functionality revolves around retrieving and managing slot configuration efficiently.

Installation

Install the library using npm or yarn. This will set up the required package and handle any dependencies automatically.

npm

npm install @bygd/opus-gpt-slot-hl

yarn

yarn add @bygd/opus-gpt-slot-hl

Usage

To use the library, import the library and utilize the primary exported function to obtain and configure ad slots. The function primarily relies on the hl_config parameter, which can be auto-fetched or provided directly.

Example

Here's a basic example demonstrating how to use the library to configure an ad slot:

import getSlotConfig from '@bygd/opus-gpt-slot-hl';

async function configureAdSlot() {
  // Define the parameters for the ad slot
  const parameters = {
    page_url: 'https://example.com',
    page_type: 'article',
    asset_id: '123456',
    slot_id: 'header-banner',
    sizes: [[728, 90]], // Custom size for the ad slot
    targeting: {
      age: '30-40',
      interest: 'technology'
    }
  };

  // Get slot configuration function
  const { getSlot } = await getSlotConfig(parameters);

  // Retrieve the ad slot configuration
  const slotConfig = await getSlot();

  console.log(slotConfig);
  // {
  //   adUnitPath: '/networkCode/adUnitCode',
  //   sizes: [[728, 90]],
  //   targeting: { age: '30-40', interest: 'technology', existingKey: 'existingValue' }
  // }
}
configureAdSlot();

Examples

Basic Slot Configuration

Configure an ad slot with custom parameters:

import getSlotConfig from '@bygd/opus-gpt-slot-hl';

async function loadAd() {
  const parameters = {
    page_url: 'https://example.com',
    slot_id: 'sidebar',
    sizes: [[300, 250]]
  };

  const { getSlot } = await getSlotConfig(parameters);
  const slotConfig = await getSlot();

  console.log('Ad Unit Path:', slotConfig.adUnitPath);
  console.log('Ad Sizes:', slotConfig.sizes);
  console.log('Targeting:', slotConfig.targeting);
}
loadAd();

Using Default Slot Sizes and Targeting

Skip defining sizes and let the library use default configurations from hl_config:

import getSlotConfig from '@bygd/opus-gpt-slot-hl';

async function loadDefaultAd() {
  const parameters = {
    page_url: 'https://example.com',
    slot_id: 'footer'
  };

  const { getSlot } = await getSlotConfig(parameters);
  const slotConfig = await getSlot();

  console.log('Ad Unit Path:', slotConfig.adUnitPath);
}
loadDefaultAd();

Acknowledgement

This guide leverages Google's GPT API for ad slot configurations. Special thanks to contributors and collaborators involved in the development and maintenance of this library.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  hl_config:
    description: Configuration object for high-level settings.
    type: object
  page_url:
    description: The URL of the page where the ad will be displayed.
    type: string
  page_type:
    description: The type of the page, used in fetching configuration.
    type: string
  asset_id:
    description: Identifier for the asset associated with the page.
    type: string
  slot_id:
    description: Identifier for the ad slot.
    type: string
  sizes:
    description: Dimensions for the ad slot.
    type: array
    items:
      type: array
      items:
        type: integer
  targeting:
    description: Key-value targeting for ads, used for additional ad configurations.
    type: object
    additionalProperties:
      type: string
required:
  - page_url
  - page_type
  - asset_id
  - slot_id