Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #943119

    Hi guys,

    I was looking at an old post on Google Analytics event tracking (, and tried to replicate it on my website.

    Here is the code :

    function add_custom_script(){
        $(window).load(function() {
        	 $('.button-1 a').on('click', function() {
                 ga('send', 'event', 'button', 'click', 'button-1');
    add_action('wp_footer', 'add_custom_script');

    The enfold editor tells me that ther is a syntax error with the “if” conditionnal.
    When I delete the “If” conditional the whole thing works, but I need the “if” conditional to use this script only on one page…
    Could you guys help me please ?


    well if you only have one page get rid of array. – and btw. i think there is one round bracket missing

    but try 


    Are you adding that in a Code Block or something similar? If so then it likely won’t work, please try it in functions.php in your child theme instead.

    Best regards,


    Hi Guenni007,

    Thanks for the help !!!


    Hey pberquet,

    Did you need further help with this topic or shall we close?

    Best regards,
    Jordan Shannon

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.