Conversion tags and tracking purchases

After becoming familiar with conversion tracking set up, use this page to learn more about the technical aspects of conversion tracking.

The conversion “tag” that we generate is a few lines of Javascript. You’ll place this code in the HTML of any pages you want to track, just before the “</body>” tag that will be at the end of your page.

Only pages that have a conversion tag (the code you generated) will be tracked. You should create a different tag for each page.

Placing transaction value and order quantity code

Conversion tracking automatically logs traffic and the path someone takes through your tagged pages, but to record how much someone is spending or the amount they’re buying, you need this additional code. Add it before the “</body>” tag on a page you want to track, instead of the regular tag code. The code is also different if you are using a third-party tracker.

Code snippet
          <script src="//platform.twitter.com/oct.js" type="text/javascript"></script>
<script type="text/javascript">
twttr.conversion.trackPid('[Insert Tag ID Here]', {tw_sale_amount: AMOUNT_HERE, tw_order_quantity: QUANTITY_HERE });</script>
<noscript>
<img height="1" width="1" style="display:none;" alt=" " src="https://analytics.twitter.com/i/adsct?txn_id=[Insert Tag ID Here]&p_id=Twitter$tw_sale_amount=AMOUNT_HERE&tw_order_quantity=QUANTITY_HERE" />
<img height="1" width="1" style="display:none;" alt=" " src="//t.co/i/adsct?txn_id=[Insert Tag ID Here]&p_id=Twitter$tw_sale_amount=0&tw_order_quantity=0" />
</noscript>
      

Third-party tracking tools

We support the following third-party container tags:

  • Floodlight tags (e.x., Google Tag Manager, DoubleClick for Advertisers)
  • Universal action tags (e.x., Atlas)
  • Server-direct (“tagless”) integration with Signal

If you would like to learn the amount or quantity of the transactions taking place on your site and are using third-party tracking, you will use this code to tag your pages:

Code snippet
          <img height="1" width="1" style="display:none;" alt=" " src="https://analytics.twitter.com/i/adsct?
txn_id=l4vsO&p_id=Twitter&tw_sale_amount=AMOUNT_HERE&tw_order_quantity=QUANTITY_HERE" / >
      

Setting “AMOUNT_HERE” and “QUANTITY_HERE” values

For your transaction value and order quantity code to work properly, you have to customize your tag. The customization can be a “hardcoded transaction” that always reports the same result when an action takes place, or a “dynamic transaction” that records richer figures.

  • Hardcoded conversions are helpful if you’d like to record the same value each time. For example, if you’ve decided that someone signing up to your email list yields a value of $15 to your company, a hardcoded conversion could be placed on your “Thank you for signing-up!” page to record $15 for every sign-up.
  • Dynamic transactions should be used when you don’t want a pre-determined value assigned to each conversion. For example, if you define a conversion as a purchase and an individual’s total is $53.72, a dynamic transaction would report that amount in your Twitter Ads account. To enable this feature, you’ll need a developer to create the code or parameter that you’ll place in the “AMOUNT_HERE” or “QUANTITY_HERE” sections of the conversion tag’s code.

How to verify website tags 

Your tag begins sending data to ads.twitter.com the first time someone visits your tagged web page. Your tag doesn’t need to be activated to collect data, but if you are experiencing problems with your tag or you just want to be thorough — use these steps to explore the code for your site and verify that your website tag is placed and working properly.

Using Google Chrome

  1. Visit a page which includes a conversion tag.

  2. In your Chrome toolbar click View > Developer > Developer Tools.

  3. Click on the “Network” tab.

  4. Type “Twitter” in the filter search box and refresh the page.

  5. Check that there are two pixels installed. One should have “t.co” as the path (this is for mobile); the other should say “analytics.twitter.com” (this tracks desktop conversions).

  6. Check that the “Status” column says “200.”

  7. If you are using container tags, they will also be displayed here.

  8. In another window, navigate to your “Conversion tracking” page under “Tools” on ads.twitter.com.

    Code snippet
              <script src="//platform.twitter.com/oct.js" type="text/javascript">
    </script>
    <script type="text/javascript">twttr.conversion.trackPid('[Insert Tag ID Here]', {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=[Insert Tag ID Here]&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=[Insert Tag ID Here]&p_id=Twitter$tw_sale_amount=0&tw_order_quantity=0" />
    </noscript>
          
  9. Click “edit” to see your conversion tag and leave this page open for reference.

  10. Go back to your tracked page, right click and choose “Inspect Element.”

  11. Hit Command + “F” to bring up a search bar and type “twitter.”

  12. By scrolling through your code’s mentions of “twitter” you should be able to find the snippet of code that matches your tag.

  13. If you do not see your tag in the code, try reinstalling your website tag.

Using Mozilla Firefox

  1. Visit a page which includes a conversion tag.

  2. In your Firefox toolbar click Tools > Web Developer > Network.

  3. Scroll down and check for “t.co” (this tracks mobile conversions) and “analytics.twitter.com” (this tracks desktop) in the “Domain” column.

  4. Check that the “Status” column says “200.”

  5. If you are using container tags, they will also be displayed here.

  6. In another window, navigate to your “Conversion tracking” page under “Tools” on ads.twitter.com.

    Code snippet
              <script src="//platform.twitter.com/oct.js" type="text/javascript">
    </script>
    <script type="text/javascript">twttr.conversion.trackPid('[Insert Tag ID Here]', {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=[Insert Tag ID Here]&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=[Insert Tag ID Here]&p_id=Twitter$tw_sale_amount=0&tw_order_quantity=0" />
    </noscript>
          
  7. Click “edit” to see your conversion tag and leave this page open for reference.

  8. Go back to your tracked page, right click and choose “Inspect Element.”

  9. Hit Command + “F” to bring up a search bar and type “twitter.”

  10. By scrolling through your code’s mentions of “twitter” you should be able to find the snippet of code that matches your tag.

  11. If you do not see you tag in the code, try reinstalling your website tag.

Ready to advertise on Twitter?