Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7991285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:14:48+00:00 2026-06-04T13:14:48+00:00

I have all the Google Analytics code between the and in my HTML file.

  • 0

I have all the Google Analytics code between the and in my HTML file. These stats are processed correctly.

After a onclick event on my , function below is called and I would like to send an event to Google Analytics, but it is never received. What am I doing wrong?

public static native void googleAnalyticsEvent(String boxId) /*-{
_gaq.push(['_trackEvent', boxId , 'Click']);
}-*/;

FYI, if I replace this code for the below, an alert is correctly displayed:

public static native void googleAnalyticsEvent(String boxId) /*-{
alert(boxId);
}-*/;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:14:50+00:00Added an answer on June 4, 2026 at 1:14 pm

    Try:

    public static native void googleAnalyticsEvent(String boxId) /*-{
        $wnd._gaq.push(['_trackEvent', boxId , 'Click']);
    }-*/;
    

    From https://developers.google.com/web-toolkit/doc/1.6/DevGuideCodingBasics#DevGuideJavaScriptNativeInterface

    “Note that the code did not reference the JavaScript window object
    directly inside the method. When accessing the browser’s window and
    document objects from JSNI, you must reference them as $wnd and $doc,
    respectively. Your compiled script runs in a nested frame, and $wnd
    and $doc are automatically initialized to correctly refer to the host
    page’s window and document.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some C# code that generates google maps. This codes looks at all
I have a navigation based application. All of the Google Analytics examples I see
I'm trying to work with another companies google analytics code. Unfortunately I don't have
I have read all the docs I can get my hands on and google'd
IS this straightforward? Does any one have any good examples? All my google searches
what I have: a google search form (displayed on all pages) a wordpress page
I have added a click listener to all my Markers in google maps. I
I have a site that leverages both Google Analytics and Google Maps. Both of
I have some problem to get the Google Analytics to work. I have got
I'm trying to track all links clicked with Google Analytics as events. So I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.