or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-2/

Page View Analytics Tracker

Configure a Nuxt.js 2 application to automatically track page views when users navigate between routes.

Requirements

Your implementation should:

  1. Configure Google Analytics: Set up tracking for property ID UA-123456789-1
  2. Enable automatic page tracking: Page views should be recorded automatically on route navigation
  3. Support manual page tracking: Allow programmatic tracking of page views when needed
  4. Handle development mode: Analytics should be disabled in development mode by default

Configuration

Configure the analytics integration in nuxt.config.js:

export default {
  buildModules: [
    // Your configuration here
  ]
}

Test Cases

  • Navigating from /home to /about automatically records a page view for /about @test
  • Manually triggering page tracking with a route object records a page view @test
  • Analytics module is disabled by default in development mode @test

Implementation

@generates

API

// Plugin should inject $ga instance globally
// this.$ga - available in Vue components
// ctx.$ga - available in Nuxt context (asyncData, plugins, middleware)

// Manual page tracking
this.$ga.page(route)

Dependencies { .dependencies }

@nuxtjs/google-analytics { .dependency }

Provides Google Analytics integration for Nuxt.js applications

@satisfied-by