docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a Nuxt.js plugin that provides a utility for tracking user interactions in a Nuxt application with Google Analytics. The utility should be accessible throughout the application and track various types of user events.
Create a plugin that provides an EventTracker class with the following capabilities:
The EventTracker should be instantiated once and made available throughout the Nuxt application via a plugin injection. It should leverage the analytics integration already configured in the application.
/**
* EventTracker class for tracking various user interactions
*/
class EventTracker {
/**
* Tracks a button click event
* @param {string} buttonLabel - The label/text of the button
* @param {string} currentPage - The current page path where the button was clicked
*/
trackButtonClick(buttonLabel, currentPage) {}
/**
* Tracks a form submission event
* @param {string} formName - The name of the form
* @param {string} status - The submission status (e.g., 'success', 'error')
*/
trackFormSubmit(formName, status) {}
/**
* Tracks a video interaction event
* @param {string} videoTitle - The title of the video
* @param {string} action - The action performed (e.g., 'play', 'pause')
* @param {number} timestamp - The current video timestamp in seconds
*/
trackVideoInteraction(videoTitle, action, timestamp) {}
}
/**
* Nuxt plugin that injects the EventTracker instance
* Makes tracker available as $eventTracker in Vue components and ctx.app.$eventTracker in Nuxt contexts
*/
export default function (context, inject) {}Provides Google Analytics integration for Nuxt.js applications with the $ga instance accessible throughout the application.