Giter Club home page Giter Club logo

metrika-nuxt3-rc9's Introduction

Yandex Metrika for Nuxt 3

npm version npm downloads License

Disclaimer

This package is a fork for those who don't want to wait for the official release of a Yandex Metrika module.

The module was created by Nuxt Community and rewritten by dankerow to support Nuxt 3. All credit belongs to:

This package includes precompiled scripts to let people integrate Yandex Metrika into their project. There's no need to compile anything, it is ready to be used out of the box.

Route change events by default

This module automatically sends first page and route change events to Yandex Metrika.

Note: Yandex Metrika is not enabled in dev mode. You can set environment variable NODE_ENV to production for testing in dev mode.

Setup

  • Add metrika-nuxt3-rc9 dependency using yarn or npm to your project
  • Add metrika-nuxt3-rc9 to modules section of nuxt.config.js
{
  modules: ["metrika-nuxt3-rc9"];
}

Configure

You can pass options directly in module declaration:

{
  modules: [
    [
      "metrika-nuxt3-rc9",
      {
        id: "XXXXXX",
        webvisor: true,
        // consoleLog: true,
        // clickmap: true,
        // useCDN: false,
        // trackLinks: true,
        // accurateTrackBounce: true,
      },
    ],
  ];
}

Or you can specify yandexMetrika key:

{
  modules: ['metrika-nuxt3-rc9'],
  yandexMetrika: {
    id: 'XXXXXX',
    // ...
  }
}

In Nuxt 2.13+, you can also use public runtime config:

{
  modules: ['metrika-nuxt3-rc9'],
  publicRuntimeConfig: {
    yandexMetrika: {
      id: process.env.YANDEX_METRIKA_ID,
      // ...
    }
  }
}

Options

For more information:

| Name | Default value | Type | Description | | ------------------- | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | accurateTrackBounce | true | Boolean | Number | Accurate bounce rate The parameter can accept these values: true — Enable the accurate bounce rate, with a non-bounce event registered after 15000 ms (15 s). false — Don't enable the accurate bounce rate. (integer) — Enable the accurate bounce rate. Non-bounce events are recorded after ms. | | childIframe | false | Boolean | Whether to record iframe contents without a tag in a child window | | clickmap | true | Boolean | Whether to collect data for a click map | | defer | false | Boolean | Whether to disable automatically sending data during tag initialization | | ecommerce | false | Boolean | String | Array | Collect data for e-commerce — Ecommerce. true — Enable e-commerce data collection. Data is transmitted via a JavaScript array named dataLayer in the global namespace (window.dataLayer) false — Disable Ecommerce data collection. (String) — Enable Ecommerce data collection. Data is transmitted via a JavaScript array named in the global namespace (window.) (Array) — Enable Ecommerce data collection. Data is transmitted via a JavaScript | | params | — | Object | Array | Session parameters transmitted during tag initialization To transmit session parameters at any other time, use the params method | | userParams | — | Object | Parameters of site users that are transmitted when initializing the tag To transmit user parameters at any other time, use the userParams method | | trackHash | false | Boolean | Hash tracking in the browser's address bar | | trackLinks | true | Boolean | Track clicks on outbound links | | trustedDomains | — | Array | Indicates a trusted domain for recording the contents of a child iframe. Contains the domain address of the parent window | | type | 0 | Number | Tag type. 1 for YAN | | webvisor | false | Boolean | Whether to use Session Replay | | triggerEvent | false | Boolean | Whether to check if the tag is ready |

Development

  • Clone this repository
  • Install dependencies using yarn install
  • Run yarn dev:prepare to generate type stubs.
  • Use yarn dev to start playground in development mode.

License

MIT License

metrika-nuxt3-rc9's People

Contributors

kondrieger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.