I have strange problem and can't find solution at all. I want to track Place order button clicks on Woocommerce checkout, but when I add onClick action on input, site just doesn't load. If I change single qoutes with double qoutes site loads but GA Events are not tracked.

Anyone have similar problem or know the solution?

    <div class="form-row place-order">
        <?php echo sprintf( esc_html__( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the %1$s Update Totals %2$s button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'norebro' ), '<em>', '</em>' ); ?>
        <br/><input type="submit" class="button alt" name="woocommerce_checkout_update_totals" value="<?php esc_attr_e( 'Update totals', 'norebro' ); ?>" />

    <?php wc_get_template( 'checkout/terms.php' ); ?>

    <?php do_action( 'woocommerce_review_order_before_submit' ); ?>

    <?php echo apply_filters( 'woocommerce_order_button_html', '<input type="submit" onClick="ga( 'send', 'event', 'button', 'click', 'placeorder' );" class="btn btn-brand full-width" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '" />' ); ?>

    <?php do_action( 'woocommerce_review_order_after_submit' ); ?>

    <?php wp_nonce_field( 'woocommerce-process_checkout' ); ?>

  • Does your webserver's error log show any errors? (It should, if PHP is encountering a fatal error)
    – Gray
    Commented Sep 9, 2018 at 23:04

1 Answer 1


Your input line is enclosed in single quotes, so when PHP sees the single quote inside that string, it thinks you're done with the string and jumping back into PHP.

The way to fix this is to escape quotes inside the string so the single quoted words inside ga() change from 'send' to \'send\'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.