• Resolved Peter Berger

    (@petercabrinha)


    Hi I trying to add a Twitter Website tag to my website. This Websitetag is for counting conversions from a Twitter campaign. I hoped I can use Code Snippers to do add the code. But I get an error message.

    The snippet has been deactivated due to an error on line 1:
    syntax error, unexpected ‘<‘

    The code
    <!– Twitter single-event website tag code –>
    <script src=”//platform.twitter.com/oct.js” type=”text/javascript”></script>
    <script type=”text/javascript”>twttr.conversion.trackPid(‘nuj9y’, { tw_sale_amount: 0, tw_order_quantity: 0 });</script>
    <noscript>
    <img height=”1″ width=”1″ style=”display:none;” alt=”” src=”https://analytics.twitter.com/i/adsct?txn_id=nuj9y&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0&#8243; />
    <img height=”1″ width=”1″ style=”display:none;” alt=”” src=”//t.co/i/adsct?txn_id=nuj9y&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0″ />
    </noscript>
    <!– End Twitter single-event website tag code –>

    I am pretty new to WordPress, so I might do something really studip 🙂

    https://wordpress.org/plugins/code-snippets/

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi,

    You’re receiving this error because you are trying to use the wrong sort of snippet with this plugin. It’s designed to work with PHP code snippets which don’t directly produce output, like you might find in a plugin or a theme’s functions.php file.

    Fortunately, there is a way to convert your HTML code into a proper PHP snippet:

    add_shortcode( 'twitter_conversation_count', function () { ?>
    
    <!-- Twitter single-event website tag code -->
    <script src="//platform.twitter.com/oct.js" type="text/javascript"></script>
    <script type="text/javascript">twttr.conversion.trackPid('nuj9y', { tw_sale_amount: 0, tw_order_quantity: 0 });</script>
    <noscript>
    <img height="1" width="1" style="display:none;" alt="" src="https://analytics.twitter.com/i/adsct?txn_id=nuj9y&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0" />
    <img height="1" width="1" style="display:none;" alt="" src="//t.co/i/adsct?txn_id=nuj9y&p_id=Twitter&tw_sale_amount=0&tw_order_quantity=0" />
    </noscript>
    <!-- End Twitter single-event website tag code -->
    
    <?php } );

    As you can see, all I have done is wrapped it in a shortcode function so you can just use the [twitter_conversation_count] shortcode in posts and pages. If you’d prefer to use a shorter and more meaningful name, just change the value in the code above.

Viewing 1 replies (of 1 total)
  • The topic ‘syntax error, unexpected '’ is closed to new replies.