Efficient Tracking: Triggering multiple inline OnClick events with just one click

I am looking to trigger multiple inline OnClick events with just one click.

The first action is the Facebook share dialog box, which is working correctly.

However, the second action where {ga(...) } triggers an event goal in Google (Universal) Analytics is not functioning properly. The goal is not being recorded in GA as expected.

<a 
class="facebook-share" 
href="#" 
onclick="
   window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
   'facebook-share-dialog', 
   'width=626,height=436'); 
   return false; 
   ga('send', 'event', 'social share', 'facebook share', 'top button' );
"> 
   Share on Facebook
</a>

Does anyone have a solution to ensure that both the FB share dialog pops up and the click is successfully tracked in GA?

Answer №1

The return false is located between calls, causing the handler to exit prior to the second call. Move it after the call to the ga() function.

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 tailor a SELECT statement option to reveal a specific div on a different webpage?

Whenever I click on a drop-down list, it redirects me to the same page. What I actually want is for each drop-down option to lead to different pages within my project. Can someone please assist me with this? Below is the PHP code snippet responsible for h ...

"An issue has been encountered with lastID being undefined while using sqlite3 with Node

After successfully inserting into the database, I am encountering an issue where this.lastID is undefined. Can anyone help me troubleshoot this code? app.post('/products/create', (req,res) => { upload(req, res, (err) => { c ...

Switch the ngClass on the appropriate ancestor element for the dropdown menu

Utilizing Angular CLI version 8.3.0, I aim to construct a sidebar featuring a drop-down menu. My objective is to apply the "open" class to toggle the opening of the drop-down section. However, the current challenge I am encountering is that when I click to ...

What is the best way to extract the ID from a dynamic "ul" tag?

Let me explain the scenario I'm facing. Currently, I have a button in my HTML code that triggers a function to generate content from another button upon selection. In the HTML code, there is a ul tag containing li tags which are populated dynamically ...

Creating a dynamic table in HTML by parsing nested JSON data with ajax

Below is an example of the JSON data I am working with. I have been struggling to display it properly in an HTML table, as it only shows 3 columns with "undefined" values. How can I correctly access and display my JSON data? { "count": 3, "entries": [ ...

What is causing the error message "Uncaught TypeError: Cannot read properties of null (reading 'push')" to be displayed when running this code?

I encountered an issue while trying to run this code which resulted in an Uncaught TypeError: Cannot read properties of null (reading 'push') console.log("HI"); let addbtn = document.getElementById("addbtn"); addbtn.addEventLi ...

Error with setting innerHTML property of a null nested div

This issue arises when the element is referenced before the DOM has completely loaded. To combat this, I have ensured that the necessary script runs only after the window has finished loading. Interestingly, if the getElementById() call is for a standalon ...

Is there a way to obtain the value of the <h3> tag for a checked radio button?

New.html.erb <div id="monthly_plan"> <% @monthly_plans.each_with_index do |plan, index| %> <div class="col-sm-6"> <input type="radio" name="subscription[plan_id]" id="plan_<%= plan.try(:id) %>" value="<%= p ...

Is there support for importing named exports in the experimental ES Module loading feature of NodeJS?

Consider the code snippet below: import { publishObjectAsync, consumeObjectsAsync, createChannelAsync } from "../shared/messaging/rabbitmq" This code results in the following error message: SyntaxError: The requested module does not provide an export ...

Achieve a scrolling effect for just a specific section of an HTML page

Hey there! I'm currently working on adding scrolling text along the side of a webpage for a specific section. My goal is to have three different sections, each with text that stops scrolling when you reach it and then transitions to the next section o ...

Accessing a SOAP web service using JavaScript

Can anyone provide guidance on calling a SOAP Service using the following URL: http://localhost:8088/...TestService?wsdl I am interested in learning how to invoke and extract values from the client side using javascript. Any tips or examples would be gre ...

Ways to add a javascript file without the ability to access the head tag

In the web framework I'm currently working with, I can insert JavaScript into the page but don't have access to add content to the head tag. Is it possible for me to dynamically include a new JavaScript file in this scenario? What specific JavaSc ...

Edit CSS attributes within Angular 2+ framework

When using jQuery, we have the ability to do the following: JQuery('.someStyle') .css({"background", "red"}) This allows us to directly change the CSS property in style. While working with Angular 2+, we can use [style.<property>] for ...

What is the best way to evaluate two objects with varying data types?

Is it possible to compare two objects with different data types? var a = { sort: 7, start: "0"} var b = { sort: "7", start: "0"} I thought they should be equal, but when I try using JSON.stringify(a) === JSON.stringify(b), it returns false. ...

Discover the items that a line intersects within the realm of three.js

I am currently immersed in a three.js project that involves selecting two boxes from a board and drawing a straight line to connect them. Once this is done, the goal is to highlight all the boxes that the line intersects. My main challenge at the moment is ...

Utilizing recorder.js to incorporate audio recording functionality into web2py

I am currently working on a web application where I need to integrate the recorder.js file for audio recording functionality. However, I am facing issues in implementing it within the web2py framework. Can you provide detailed guidance on how to utilize th ...

How can I create a responsive design for my div elements?

I am facing an issue with responsiveness in my div container. Inside the square-shaped frame, I have a h2 tag that does not adjust properly when viewed on different devices such as mobile and browsers. Despite setting up media queries to make it responsive ...

Performing a fetch request within a directive on the Ionic Framework

I am currently working on customizing the angular-pickdate module from https://github.com/jimibi/angular-pickadate to meet my specific requirements. However, I have hit a roadblock because I am unable to make a GET request in the traditional way that I am ...

I encountered an error with status code 401 despite providing the API token as required

Can anyone help me troubleshoot an issue I'm having with a POST request using VueJS in Laravel? The request keeps failing with a 401 status code, even though I'm passing the token in the headers. const post_data = { headers: { Authoriza ...

Encountering a CORS issue when utilizing Stripe with various servers while navigating with a Router

I have a router that utilizes Router.express(). The backend operates on port 5000, while the frontend runs on port 3000. Within the frontend folder, there is a button with a fetch request (http://localhost:5000/create-checkout-session). In the backend, the ...