Adding Google Analytics to NuxtJS app

Setting up Google Analytics Account

  • Go to Google Analytics home page
  • Sign in with your google account (otherwise Sign Up)
  • Click on the Admin icon on the left pane admin create account analytics
  • Create an account for the website by providing the details for the property to measure, which in this my business website: Skynet Technology Ltd analytics ga4 account setup 01

    • Provide the details about the business
  • Click DataStreams under the property column and create a new Web Stream analytics ga4 account setup 02
  • Finally something like the following should appear on the screen with a Measurement ID that is of the format G-XXXXXXX. Make a note of this analytics ga4 account setup 03
  • Now go in the Source code of the NuxtJS app and create a folder called plugins at the root with a file called gtag.js js app setup 01
  • Install the vue-gtag package using yarn (or npm if you use it). Please note "vue-gtag": "^1.16.1" is the working version with this setup.
yarn add vue-gtag
  • Add the following to the plugins/gtag.js file. Replace the value against id by providing the Measurement ID shown in the earlier step
import Vue from "vue";
import VueGtag from 'vue-gtag';

Vue.use(VueGtag, {
    config: {id: 'G-XXXXXXXXXX'}
})
  • Add the path to the created plugin in nuxt.config.js file at the root

    plugins: [
    '@/plugins/gtag'
    ],
    

    js app setup 02

That's mostly it. Just follow through your deployment process and should see the real time stats as a method of verification verification realtime

References

Latest Blogposts

SLURM Demo on AWS Ubuntu EC2 instance

Demo of slurm usage on a single instance of Ubuntu 24.04 EC2 instances on AWS

29 May 2024

SLURM on WSL

Setting up SLURM on WSL

27 May 2024

Introduction to SLURM

Simple Linux Utility for Resource Management (SLURM)

26 May 2024

How to find a linux machine is a VM (Virtual Machine) or a Bare Metal

If you can SSH into a linux machine and want to find out if its baremetal or Virtual Machine

7 November 2023

Storing Github access token in git credential store

Using git credentials store the github access token to avoid the re-prompting of username and pwd

4 April 2023

Token generation for Registering Self Hosted Github Runner via REST API

Explains how to generate a token using github API to be used in turn with Github self hosted runner registration

21 March 2023