How to use @segment/snippet - 5 common examples

To help you get started, we’ve selected a few @segment/snippet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github segmentio / evergreen / docs / gatsby-ssr.js View on Github external
(function () {
        // analytics.js stub
        const analytics = window.analytics = {}
        const methods = [
          'trackSubmit', 'trackClick', 'trackLink', 'trackForm', 'pageview',
          'identify', 'reset', 'group', 'track', 'ready', 'alias', 'debug',
          'page', 'once', 'off', 'on', 'load'
        ]
        methods.forEach(method =>
          analytics[method] = (...args) => console.log(\`analytics.\${method}\`, ...args)
        )
      })()
    `
  }

  return createSnippet({ apiKey: writeKey, page: false })
}
github zeit / next.js / examples / with-segment-analytics / pages / _document.js View on Github external
renderSnippet() {
    const opts = {
      apiKey: ANALYTICS_WRITE_KEY,
      // note: the page option only covers SSR tracking.
      // Page.js is used to track other events using `window.analytics.page()`
      page: true,
    }

    if (NODE_ENV === 'development') {
      return snippet.max(opts)
    }

    return snippet.min(opts)
  }
github reactioncommerce / example-storefront / src / custom / analytics / segment.js View on Github external
export function renderScript() {
  const { publicRuntimeConfig: { segmentAnalytics } } = getConfig();

  const opts = {
    apiKey: segmentAnalytics.writeKey,
    page: true // Set this to `false` if you want to manually fire `analytics.page()` from within your pages.
  };

  if (segmentAnalytics.skipMinimize === true) {
    return snippet.max(opts);
  }

  return snippet.min(opts);
}
github reactioncommerce / example-storefront / src / custom / analytics / segment.js View on Github external
export function renderScript() {
  const { publicRuntimeConfig: { segmentAnalytics } } = getConfig();

  const opts = {
    apiKey: segmentAnalytics.writeKey,
    page: true // Set this to `false` if you want to manually fire `analytics.page()` from within your pages.
  };

  if (segmentAnalytics.skipMinimize === true) {
    return snippet.max(opts);
  }

  return snippet.min(opts);
}
github zeit / next.js / examples / with-segment-analytics / pages / _document.js View on Github external
renderSnippet() {
    const opts = {
      apiKey: ANALYTICS_WRITE_KEY,
      // note: the page option only covers SSR tracking.
      // Page.js is used to track other events using `window.analytics.page()`
      page: true,
    }

    if (NODE_ENV === 'development') {
      return snippet.max(opts)
    }

    return snippet.min(opts)
  }

@segment/snippet

Templating methods for rendering the analytics.js snippet.

MIT
Latest version published 10 months ago

Package Health Score

67 / 100
Full package analysis

Popular @segment/snippet functions

Similar packages