Title: Having trouble adding onclick Javascript code
Last modified: August 20, 2016

---

# Having trouble adding onclick Javascript code

 *  [shauli](https://wordpress.org/support/users/shauli/)
 * (@shauli)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-adding-onclick-javascript-code/)
 * Hi,
    I’m trying to add some code to my responsive Theme so that when someone 
   clicks on the download button it’s tracked by Google Analytics. This is the code
   that I put in the editor /
 *     ```
       echo '<a href="http://www.videoto.org">Visit Products Page</a> '"$options['cta_url'].'" class="blue button">';
       					echo $options['cta_text'];
       				    echo '';
       ```
   
 * but now when I go to my site, I see this error message
 * Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /home/
   content/65/9642965/html/wp-content/themes/responsive/home.php on line 79.
    Not
   quite sure what this means or where my error is. If it helps the webste is [http://www.videoto.org](http://www.videoto.org)
   and I’m using the Responsive theme. Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-adding-onclick-javascript-code/#post-3135387)
 * This bit,
 *     ```
       '"$options['cta_url'].'" class="blue button">';
       ```
   
 * Is not part of the anchor,
 *     ```
       <a href="http://www.videoto.org">Visit Products Page</a>
       ```
   
 * The error will probably persist but let’s start with this.
 *  Thread Starter [shauli](https://wordpress.org/support/users/shauli/)
 * (@shauli)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-adding-onclick-javascript-code/#post-3135390)
 * This is weird, I just looked at the code I entered and its missing the onclick
   part. The entire snippet should have been
 *     ```
       echo '<a href="http://www.videoto.org" onClick="_gaq.push(['_trackEvent', 'Link Clicks', 'downloads',
       'The product link on the sales page']);">Visit Products Page</a> '"$options['cta_url'].'" class="blue button">';
       					echo $options['cta_text'];
       				    echo '</a>';
       ```
   
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-adding-onclick-javascript-code/#post-3135392)
 * You’re closing your string on trackEvent as well.
 *  Thread Starter [shauli](https://wordpress.org/support/users/shauli/)
 * (@shauli)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-adding-onclick-javascript-code/#post-3135393)
 * Hey Andrew,
    Thanks for helping me out here, I don’t have a lot of coding knowledge,
   so I’m not sure what you mean I’m closing the string on trackEvent as well.
 * Do I not want to close the string, and if so, how do I open it.
 * Thanks again
    Shauli

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Having trouble adding onclick Javascript code’ is closed to new replies.

## Tags

 * [javascript error](https://wordpress.org/support/topic-tag/javascript-error/)
 * [onclick](https://wordpress.org/support/topic-tag/onclick/)
 * [Responsive Theme](https://wordpress.org/support/topic-tag/responsive-theme/)
 * [ThemeID](https://wordpress.org/support/topic-tag/themeid/)

 * 4 replies
 * 2 participants
 * Last reply from: [shauli](https://wordpress.org/support/users/shauli/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/having-trouble-adding-onclick-javascript-code/#post-3135393)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
