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

@web3analytic/retargeting-sdk

v1.0.2

Published

Web3Analytic's typescript package for in-dapp retargeting

Downloads

4

Readme

retargeting-sdk

Web3Analytic's javascript SDK for in-dapp retargeting

The goal of retargeting is to guide a user who has performed a source action to then perform a target action. A common example might be encouraging users to perform an on-chain swap after an approval.

Install

npm install @web3analytic/retargeting-sdk

Usage

The most important function to import is registerAction which takes as input an address interacting with your protocol frontend, along with information about an action.

import { registerAction } from '@web3analytic/retargeting-sdk';

You can register both on-chain and off-chain actions. For on-chain actions, you must provide the chain and the transaction hash (txHash). These can be obtained from any wallet provider (e.g. MetaMask) upon an on-chain action. It is not necessary to wait for a transaction to be confirmed.

import { registerAction, RegisterActionInputType }  from '@web3analytic/retargeting-sdk';
const input: RegisterActionInputType = {
  apiKey: "...",
  address: "0x...",
  chain: "ethereum",
  txHash: "0x...",
} 
registerAction(input).then(...)

For off-chain actions, an identifier must be provided. These strings can be of any length and structure although it is important it matches the identifiers chosen during setup of this retargeting campaign through the Web3Analytic web application.

import { registerAction, RegisterActionInputType }  from '@web3analytic/retargeting-sdk';
const input: RegisterActionInputType = {
  apiKey: "...",
  address: "0x...",
  identifier: "main-page-sidebar-button-click",
} 
registerAction(input).then(...)

Source and target actions are both registered using registerAction. The SDK will automatically detect whether the action is a source or target depending on the active retargeting campaigns. If the action is a source action, it will return an impression object:

{
  hit: true,
  prompt: {
    title: ...,
    subtitle: ...
    ...,
  }
  impressionId: 120;
}

The impressionId will be useful for regsitering reactions (see next). The prompt can be used to render a notification to encourage the user to take the corresponding target action.

If the action is a target action (or alternatively the action is not a match to any retargeting campaign), the returned object will only contain a single field hit set to false.

Analytics on conversion rates between source and target actions can be found on the Web3Analytic app.

Finally, we may be interested in the proportion of users that engage with a notification shown (irrespective of whether they take the target action or not). To track this, we can call the following

import { registerReaction }  from '@web3analytic/retargeting-sdk';

await registerReaction(apiKey, impressionId);

when the user engages with the notification prompt. Note that a user performing the target action is automatically tracked through registering actions and does not require calling registerReaction. Tracking user's clicking on the notification however, requires calling registerReaction.