• 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 and I’m using the Responsive theme.
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    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

    (@shauli)

    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

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You’re closing your string on trackEvent as well.

    Thread Starter shauli

    (@shauli)

    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.