or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-8/

Analytics Integration Manager

Create a Nuxt.js 2 application module that provides flexible Google Analytics integration with support for custom script loading strategies. The module should allow developers to control when and how the Google Analytics script is loaded, and prevent conflicts when Google Analytics is already present on the page through other means (such as Google Tag Manager).

Requirements

Your implementation should support the following scenarios:

Script Loading Control

Configure the Google Analytics module to prevent automatic script loading. This is useful when you need to manually control the script loading process or when using custom loading strategies.

Duplicate Script Detection

Detect and prevent loading duplicate Google Analytics scripts when analytics is already loaded through other methods (e.g., Google Tag Manager, manually embedded scripts, or other third-party tools).

Manual Script Loading Strategy

Implement a custom script loading approach that:

  • Disables the automatic script loader
  • Checks for existing analytics scripts before attempting to load
  • Loads the Google Analytics script only when it's confirmed not to be present

Configuration

Your solution should configure a Nuxt.js 2 application with the following:

  • Google Analytics tracking ID: 'UA-123456-1'
  • Script loading behavior configured based on the requirements above

Test Cases

  • The Google Analytics module is configured with script loader disabled @test
  • The Google Analytics module is configured with duplicate script checking enabled @test
  • When both script loader is disabled and duplicate checking is enabled, the module initializes correctly @test

Implementation

@generates

API

// nuxt.config.js
export default {
  buildModules: [
    '@nuxtjs/google-analytics'
  ],
  googleAnalytics: {
    id: string,
    disableScriptLoader: boolean,
    checkDuplicatedScript: boolean
  }
}

Dependencies { .dependencies }

@nuxtjs/google-analytics { .dependency }

Provides Google Analytics integration for Nuxt.js applications with Universal Analytics (GA3) support.