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

@bolt/analytics-autolink

v5.0.0

Published

Adds Google Analytics tracking support to the Bolt Design System.

Downloads

6

Readme

Bolt Autolink

Helper library to automatically applies GA autolink click tracking query strings to Bolt components that point to external domains.

Install

npm install @bolt/analytics-autolink

Usage

Step 1. Pull in the JS bundle into your local front-end build.

  • Via Bolt's .boltrc.js config:
module.exports = {
  components: {
    global: [
      '@bolt/analytics-autolink',
      //...
    ]
  }
}
  • Or for existing build processes (ex. Webpack), simply import the main JS bundle:
// ex. main.js
import '@bolt/analytics-autolink';
//

2. Config GA + Autolink

For example, a typical GA config might look similar to this:

<head>
  <script src="https://www.google-analytics.com/analytics.js" async></script>

  <script>
    // replace with your own GA tracking #
    const TRACKING_ID = 'UA-123456789-0'; 

    // prep GA data if it doesn't yet exist
    window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args));

    ga('create', TRACKING_ID, 'auto', { allowLinker: true });
    ga('send', 'pageview');
    ga('set', 'transport', 'beacon');
    ga('require', 'linker');

    // See Step 3 below on configuring which domains to track
    // window.bolt = window.bolt || {};
    // window.bolt.analytics = window.bolt.analytics || {};
    // window.bolt.analytics.autolink = window.bolt.analytics.autolink || {
    //   domains: ['google.com'] // domains to configure
    // };
    // ga('linker:autoLink', window.bolt.analytics.autolink.domains);
  </script>

3. Configure which domains to autolink

Option 1. Via a global Bolt config. For example:

  <script>
    window.bolt = window.bolt || {};
    window.bolt.autolink = {
      domains: ['google.com'], // domains to track
    };

    // make sure GA's linker:autoLink points to the domains configured
    ga('linker:autoLink', window.bolt.autolink.domains);
  </script>

Option 2. This can also be configured via a Drupal config. For example:

  <script>
    window.drupalSettings = {
      google_analytics: {
        trackCrossDomains: ['pega.com'], // domains to track
      },
    };

    // make sure GA's linker:autoLink points to the domains configured
    ga('linker:autoLink', window.drupalSettings.google_analytics.trackCrossDomains);
  </script>