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 7521471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:14:23+00:00 2026-05-30T02:14:23+00:00

I have a webpage with a ‘Start test’ button, I would like to track

  • 0

I have a webpage with a ‘Start test’ button, I would like to track the value of an input: <input id="RepeatsInput" type="text" /> every time the button is clicked through Google analytics – bearing in mind I am using Google analytics to track the pageviews (this will have happened already before the user presses the button). What snippet of code should I use for this?

Thanks in advance.

  • 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-05-30T02:14:24+00:00Added an answer on May 30, 2026 at 2:14 am

    Since it is not known exactly how the HTML is set up, consider this example:

    HTML:

    <input id="RepeatsInput" type="text" />
    <button onclick="setCustomVar();">Start test</button>​
    

    JS:

    function setCustomVar() {
       var inputValue = document.getElementById("RepeatsInput").value;
       _gaq.push(['_setCustomVar', 1, 'YOUR-CUSTOM-VAR-NAME', inputValue]);
       _gaq.push(['_trackPageview']);
    }
    

    Google’s documentation on Custom Variables explains that another _trackPageview will need to be called for custom variables set by user events.

    Call the _setCustomVar() function when it can be set prior to a pageview or event GIF request.
    In certain cases this might not be possible, and you will need to set another _trackPageview() request after setting a custom variable. This is typically only necessary in those situations where the user triggers a session- or visit-level custom var, where it is not possible to bundle that method with a pageview, event, or ecommerce tracking call.

    Event tracking may be another way to address this.

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

Sidebar

Related Questions

I have a webpage in which I have a div that I would like
I have a webpage using a javascript. The code sample: <script type=text/javascript> var shown
I have a webpage which has 10 separate text input spaces. I need to
I have webpage with a button. when user pressing on button he get email
I have webpage where there is textbox with some default value. I have to
I have webpage with a form like this: <html> <head> ... </head> <body> <form
I have a webpage like: <html> <head> . . . </head> <body> <div id=wrapper>
I have a webpage that looks like: <html> <head> <title>Hi</title> </head> <body> <form name=mainForm
I have a webpage with a textbox and a button and when the button
I have a webpage with some mysql querys, I must start new db connection

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.