Tracking link clicks to monitor navigation away from a page using Mixpanel or Google Analytics

As I work on tracking an event that triggers when a user attempts to exit the website by clicking on a link.

<a ng-click="bookingOutside(trip,0)"  href="https://www.google.com" target="_blank">
          <button type="button" class="externalBooking">
            {{'BOOK'|translate}}
          </button>
        </a>

I'm facing an issue where the bookingOutside event isn't being activated. What could be causing this problem and what steps can I take to resolve it?

Answer №1

Setting up the event using this method within the link should work, especially if you are utilizing Universal Analytics. It's important to note that it should be placed in the <head> section and not in button format.

ga('send', 'event', 'button', 'click', 'nav-buttons')

You have the option to customize these parameters according to your preferences, as detailed in the following resource:

https://developers.google.com/analytics/devguides/collection/analyticsjs/events

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to format a text component so that the initial word in each sentence is bolded?

Creating a text component where the first word of the sentence is bold can be a bit tricky. The current solution may result in a messy output like "Tips: favouritevacation" where there is no space after "Tips:". This approach is not very elegant. One pos ...

When navigating using the next and back buttons, the active state in Angular is automatically removed

Looking for some assistance with my quiz app setup. Each question has True/False statements with corresponding buttons to select T or F. However, when I click the next/back button, the active class is not being removed from the previous selection. As a beg ...

Are mutations in Vuex guaranteed to be atomic?

I'm currently investigating the atomicity of mutations in Vuex. The code snippet I'm reviewing has me questioning whether the CHANGE_A mutation could potentially be triggered while CHANGE_B is still in progress: const mutations = { [CHANGE_A]( ...

Different options for substituting 'true' in angularJS directives

I've noticed that 'replace: true' is being phased out in AngularJS, and I understand the reasons behind it. However, I believe there are certain scenarios in AngularJS development where this feature is still valuable. My goal is to create a ...

Solving the issue of overflowing in the animation on scroll library

I've recently started using a fantastic library called animation on scroll (aos) for my web development projects. This library offers stunning and visually appealing animations. However, I encountered an issue where it causes overflow problems in my H ...

Leverage the Frontend (Headless Commerce) to utilize the Admin API and retrieve products from Shopify

Attempting to retrieve products from Shopify using the Admin API (GraphQL) through my frontend. I utilized the following code: *I implemented "axios" on Quasar Framework, utilizing Headless Commerce const response = await this.$axios({ url: "https: ...

The second jQueryUI datepicker instance flickers and vanishes when the show() function is triggered

I currently have two jQueryUI datepickers integrated into my webpage. The initialization code for both is as follows: jQuery("#departureDate").datepicker({ beforeShow: function() { getDatesForCalendar("outbound"); }, numberOfMonths: 3 ...

What steps can be taken to enhance the efficiency of this complex nested asynchronous loop?

The issue at hand involves an array of objects structured like this: let myObj = [ {'db1':['doc1','doc2','doc3']}, {'db2':['doc4','doc5']}, {'db3':['doc7','doc8 ...

Accessing JSON data model from Ember route or controller

Exploring the capabilities of Ember.js Is it possible to expose my data model as JSON through a route or controller? The object saved in the store looks like this: this.store.createRecord('Person', { id: 1, name: this.get('name'), ...

Utilizing Laravel's URL::asset method in conjunction with a JavaScript variable

Having a go at creating an HTML tag using the Jquery snippet below $("<option />",{ 'data-src':"{{ asset(my-javascript-variable) }}", id:'my_id').appendTo($('#image')); An option tag is being added to a select element. ...

Tips for Successfully Transmitting Information via Mat-Dialog

Having trouble passing data from a dialog back to the parent component. Specifically, I'm struggling with updating the value of an array in the `afterClosed` function. I've tried using `patchValue` and `setValue`, but it doesn't seem to be w ...

Styling an exponential number in a table header using Vuetify

I am looking to replace the default header 'number' with a custom HTML header while using vuetify for displaying a data table. My current setup looks like this: headers: [ {text: 'number', value: &a ...

Implementing pagination in an express application

I am faced with a situation where I have an array of JSON objects generated by a function in my running Express app. When there is only one object, it is rendered using the following Jade view. p You searched for '#{prop}' h2 Result if res ...

JavaScript is unable to make changes to the page once it has finished loading

I have implemented a JavaScript code that allows me to send messages in a chat interface: function sendMessageToChat(conversation, message) { $("#content").html(conversation + message); $(".current-msg").hide(); $(".current-msg").delay(500).fadeIn ...

Allow JavaScript to determine whether to link to an internal or external web address

Currently, I am in the process of setting up a new website and need to create an HTML page with some JavaScript that can determine whether to link to the external or internal IP address. I have researched some JavaScript code to fetch the IP address, whic ...

Access the data attribute of a button element in AngularJS

Utilizing Angularjs for managing pagination loop button id=remove_imslide, I am attempting to retrieve the value of data-img_id from the button to display in an alert message using a Jquery function on button click, but I am encountering issues. This is h ...

"Encountering an error: invalid CSRF token in Node.js csurf

I have been utilizing the npm module csurf to generate a token. Initially, I retrieve the token from the server and then utilize it for the /register request. When I replicate these steps in Postman, everything seems to function correctly, but unfortunatel ...

Dynamic JavaScript Total Calculation

I have been struggling to update the total price for specific options. Even though the code was created by someone else and has worked fine for many users, I can't seem to make it work correctly. Any assistance would be greatly appreciated. Here is t ...

Using jQuery to fetch data from a URL

Imagine having a URL such as: http://localhost:1122/MyProject/MyPage.aspx?from=home&id=454. In the code behind, I can access the 'from' value like Request["from"]. Is there a way to achieve this using JavaScript too? Can jQuery be used for ...

The lineTo() function does not support passing in an array as its argument

My goal is to draw lines based on the coordinates provided in the array called points. However, I encountered an error when calling the method. Oddly enough, when I try to access a specific element using console.log(points[1][1]), it works perfectly. Can s ...