Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs down GA Event Tracking OnClick troubleshooting

    Hello friends,
    I'm struggling here to insert a _gaq.push(['_trackEvent', on a button at my webstite.

    The original button looks like this:

    <button type="submit" class="button" title="Login" onclick="veriform.verify(1)">'. LANG::_('login') .'</button>

    What i tried to do is:

    <button type="submit" class="button" title="Login" onclick="veriform.verify(1);_gaq.push(['_trackEvent', 'IniciarProjeto', 'Cadastro', 'EntrarCadastrado',]);">'. LANG::_('login') .'</button>

    But my page appeared blank...

    Can anybody help me?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Syntactical issue. If you would actually post the entire line in a PHP markup block, you'd see the color change from red to blue.
    You need to escape those single quotes.

    Edit:
    to demonstrate this:
    PHP Code:
    echo '<button type="submit" class="button" title="Login" onclick="veriform.verify(1);_gaq.push(['_trackEvent', 'IniciarProjeto', 'Cadastro', 'EntrarCadastrado',]);">'LANG::_('login') .'</button>'
    Edit:
    BTW, enabling your error reporting would tell you what the problem is:
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 
    Code:
    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' on line X

    Last edited by Fou-Lu; 07-12-2012 at 08:50 PM.

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thx a lot Fou-Lu,

    Can you share the final code I should use at my site?! I would not know how to scape those single quotes...

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Simply place a \ in front of any single quote that is used within that string.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •