How to use the analytics function in analytics

To help you get started, we’ve selected a few analytics 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 DavidWells / analytics / examples / demo / src / utils / analytics / example-2.js View on Github external
import Analytics from 'analytics'
import googleAnalytics from '@analytics/google-analytics'
import exampleProviderPlugin from './plugins/provider-example'


/* initialize analytics and load plugins */
const analytics = Analytics({
  debug: true,
  app: 'yolo',
  plugins: [
    {
      name: 'hahahaa',
      track: () => {
        console.log('hi')
      }
    },
    {
      NAMESPACE: 'hello',
      track: () => {
        console.log('hi')
      }
    },
    exampleProviderPlugin({
github DavidWells / davidwells-legacy-site / src / utils / analytics / index.js View on Github external
const isProduction = process.env.NODE_ENV === 'production'
const isClient = typeof window !== 'undefined'
const googleAnalyticsUA = process.env.GOOGLE_ANALYTICS_UA

const logger = store => next => action => {
  if (action.type) {
    console.log(`>> dispatching ${action.type}`, JSON.stringify(action))
  }
  return next(action)
}

let analytics // eslint-disable-line
if (isClient) {
  // start analytics
  analytics = Analytics({ // eslint-disable-line
    app: 'davidwells',
    version: 1,
    plugins: [
      logger,
      googleAnalytics({
        trackingId: googleAnalyticsUA,
        autoTrack: true,
      }),
    ]
  })


  window.analytics = analytics
  console.log('analytics loaded')
}
github DavidWells / analytics / examples / react / src / analytics.js View on Github external
import Analytics from 'analytics'
import segmentPlugin from '@analytics/segment'

/* initialize analytics and load plugins */
const analytics = Analytics({
  debug: true,
  plugins: [
    segmentPlugin({
      writeKey: 'TpKoFHqy1g98bXjd3wdVp3JvkHJRl5Q5',
      disableAnonymousTraffic: true,
    }),
    exampleProviderPlugin({
      xyz: '123'
    })
  ]
})

/* This is an example plugin */
function exampleProviderPlugin(userConfig = {}) {
  return {
    NAMESPACE: 'provider-example',
github DavidWells / analytics / site / gatsby-theme-oss-docs / src / analytics.js View on Github external
import Analytics from 'analytics'
import fullStoryPlugin from '@analytics/fullstory'
import googleAnalytics from '@analytics/google-analytics'

const analytics = Analytics({
  debug: true,
  plugins: [
    fullStoryPlugin({
      org: 'NRVKK'
    }),
    googleAnalytics({
      trackingId: 'UA-126647663-4'
    }),
  ]
})

analytics.on('page', ({ payload }) => {
  console.log('page view fired', payload)
})

analytics.on('track', ({ payload }) => {
github AugurProject / augur / packages / augur-ui / src / services / analytics / analytics.ts View on Github external
import Analytics from 'analytics';
import ipfsPlugin from './plugin-ipfs';
import { isLocalHost } from 'utils/is-localhost';
import segmentPlugin from '@analytics/segment';

const analytics = isLocalHost() ? {} : Analytics({
  app: 'augur-ui',
  version: 3,
  plugins: [
    ipfsPlugin({
      ethereumNetwork: process.env.ETHEREUM_NETWORK,
      senderAccount: 'augur-ui-tracker',
    }),
    segmentPlugin({
      writeKey: "mTjvLsOUUyWObl8zkKUMAXc7TEAWqhPV"
    }),
  ],
});

export { analytics };
github DavidWells / analytics / examples / preact / src / analytics.js View on Github external
import Analytics from 'analytics'
import googleAnalytics from '@analytics/google-analytics'

const analytics = Analytics({
  app: 'app-name',
  debug: true,
  plugins: [
    googleAnalytics({
      trackingId: 'UA-126647663-2',
    }),
  ]
})

export default analytics
github netlify-labs / functions-site / src / analytics.js View on Github external
import Analytics from 'analytics'
import segmentPlugin from 'analytics-plugin-segment'
import gtagManagerPlugin from 'analytics-plugin-google-tag-manager'

const analytics = Analytics({
  plugins: [
    gtagManagerPlugin({
      containerId: 'GTM-NMKKF2M'
    }),
    segmentPlugin({
      writeKey: 'f3W8BZ0iCGrk1STIsMZV7JXfMGB7aMiW',
      disableAnonymousTraffic: true,
    }),
    {
      NAMESPACE: 'custom-analytics-plugin',
      page: ({ payload }) => {
        const { protocol, host, pathname } = window.location
        const { properties, meta, anonymousId, userId } = payload
        setTimeout(() => {
          const analyticsPayload = Object.assign({}, properties, {
            date: meta.timestamp || new Date().getTime(),