mercredi 20 mars 2019

WordPress: Echo Javascript for Google Ads Conversion Page

I'm trying to add some Javascript coming from Google for Ad Conversions on the thank you page. So this script should only appear on one page. Trying to use an if statement in PHP to echo the code but running into errors. This is what I currently have (with the Google ID replaced with something generic):

<?php if ( is_page( 'thankyou' )) {
    echo '<script>';
    echo 'gtag('event', 'conversion', {'send_to': 'AW-12345678901234567890123456'});'
    echo '</script>';
?>

The first and third echo's are fine but the middle one is not. What might be the proper fix?

Aucun commentaire:

Enregistrer un commentaire