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

@tincre/promo-sync

v0.0.5

Published

Event tracking for Ad platforms supported by Promo ads. Use in conjunction with the [`promo-button`](https://github.com/Tincre/promo-button), your Google Tag Manager and/or Google Analytics, Facebook Pixel, Meta Conversions API, and [Tincre Promo](https:/

Downloads

190

Readme

promo-sync, by Tincre.dev

Event tracking for Ad platforms supported by Promo ads. Use in conjunction with the promo-button, your Google Tag Manager and/or Google Analytics, Facebook Pixel, Meta Conversions API, and Tincre Promo.

🤯 for your ads on the web, with Google, Meta, and Tincre.

Installation

Use your favorite package manager to rock installation of promo-sync.

Yarn

yarn add @tincre/promo-sync# -D if you want this as a dev dep

Npm

npm install @tincre/promo-sync# --save-dev if you want it as a dev dep

Usage

To use a Google Tag (Analytics) event simply import it into your framework of choice and fire the function.

🌶️ Typically this is in a useEffect hook within the function body if you're a React user.

import { promoEventPageView } from '@tincre/promo-sync';

export default function PageOrComponent() {
  promoEventPageView()  
  return <></>;
}

Automagic Setup

As we at Tincre are proud Next.js users, below is a snippet you can use for performant Next.js sites.

In your pages/_app.{js,jsx,ts,tsx} file:

import Script from 'next/script';
import { promoGtag } from '@tincre/promo-sync-gtag';

export default function MyApp({component, pageProps,}) {

  return (
    <>
      <Script id="google-tag-manager" strategy={"afterInteractive"}>{promoGtag}</Script>
      <Component {...pageProps} />
    </>
  )
}

Or if you don't use React/Next.js:

import { promoGtag } from '@tincre/promo-sync';

<script type="module" src="https://unpkg.com/browse/@tincre/promo-sync@latest/dist/promo-sync.esm.js">
  import { loadPromoGtag } from '@tincre/promo-sync';
  loadPromoGtag();
</script>

As usual you can grab our minified build and link to that as a universal script, loaded prior to the code snippet directly above (and without the import statement).

Bare Metal Setup: Add the Tincre GTag

Follow the installation method below to install the Tincre Sync Gtag, if you need a custom installation. You do not need this step if you've installed via the #automagic-setup method above.

In addition, this works alongside or without a current Google Tag Manager or Analytics installation. This handles Meta ad conversions, as well.

Our tag is GTM-57QS65R.

<head>

Into the <head> of each page:

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://sync.tincre.dev/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-57QS65R');</script>
<!-- End Google Tag Manager -->
<body>

And then in the <body>:

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://sync.tincre.dev/ns.html?id=GTM-57QS65R"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

That's it!

Alongside a current Gtag installation (custom)

Just call the gtag function again, i.e.

gtag('config', 'GTM-57QS65R', {
  'transport_url': 'https://sync.tincre.dev',
  'first_party_collection': true, 
});

See the Google Tag Manager documentation for additional details.

Deduplicating Ids

You should deduplicate ids if you are installing alongside a current implementation that you'd like your Promo events to merge with prior setups, rather than add to.

Pass your event below a transaction_id value and it'll match up throughout your data from Promo and Google Tag Manager.

See this Google Ads answer for more details.

Fortunately, we already provide a means of handling this seamlessly. Simply use the following function to generate an id and instantiate it via the gtag code above.

import { generateEventId } from '@tincre/promo-sync'

const myPromoEventId = generateEventId();

🌶️ You shouldn't need to do anything if you're just installing the "stock" Tincre Sync setup. This is specifically for those who need further customization and DIY installation. Tincre typically handles this for enterprise clients and pro on request.

Add an event

To use an event simply import it and call the function, e.g.

import { promoEventPageView } from '@tincre/promo-sync'
import { useEffect } from 'react';

export default function Index({...}) {
    useEffect(() => { // run once on load
        promoEventPageView()
    }, [])
    return <></>
}

useEffect example

import { useEffect } from 'react';
import { promoEventPageView } from '@tincre/promo-sync';

export default function PageOrComponent() {
  useEffect(() => {
    promoEventPageView()  
  }, [])
  return <></>;
}

Support

License

This code is free to use for your commercial or personal projects. It is open-source licensed under the Mozilla Public License 2.0.

You will see various headers throughout the codebase and can reference the license directly via LICENSE herein.

Development

Releases

We use npm for releases. In particular, we use npm --publish to get the job done.

Currently, only @thinkjrs has the ability to release. The following section is written for memory.

Release prep

Prior to using npm --publish a release tag needs to be created for the library using our standard tagging practices.

Ensure that tests :white_check_mark: pass during this process prior to releasing via npm.

Test release

To do a proper release, ensure you're in the base repo directory and run npm publish . --access public --dry-run.

Release latest tag

To complete a full release to the latest npm dist-tag, ensure you're in the base repo directory and run npm publish . --access public.

:tada: That's it! :tada: