Hi, is there Twitter API endpoint to generate Universal Website Tag for the new Twitter account or this could be done only from Twitter UI by pressing the “Generate website tag for conversion tracking” button?

Also how can I get Universal Website Tag code snippet or Tag ID from the API once it is created? In UI I see “View code and installation instructions” link which contains Universal Website Tag setup instructions and the tag code. And there is Web Event Tags API endpoint but I can list only auto-created web event tags and not the Universal Website Tag.

@michealzub

Hi, is there Twitter API endpoint to generate Universal Website Tag for the new Twitter account or this could be done only from Twitter UI by pressing the “Generate website tag for conversion tracking” button?

I believe we don’t support creating universal website tags via API at this moment.

Also how can I get Universal Website Tag code snippet or Tag ID from the API once it is created?

You should be able to get the universal website tag information via API once you’ve created a new universal website tag.

$ twurl -H 'ads-api.twitter.com' '/5/accounts/:account_id/web_event_tags' | jq '.data[] | [.name, .id] | @csv' -r

then,

$ twurl -H 'ads-api.twitter.com' '/5/accounts/:account_id/web_event_tags/:id' | jq '.data.embed_code'

Thank you, got it.

But the code snippet I receive in the API endpoint and code snippet for the Universal Website Tag displayed in the UI are different.

Code from the API endpoint:

<script src="//platform.twitter.com/oct.js" type="text/javascript"></script><script type="text/javascript">twttr.conversion.trackPid('abcde',  { 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=abcde&amp;p_id=Twitter&amp;tw_sale_amount=0&amp;tw_order_quantity=0" /><img height="1" width="1" style="display:none;" alt=""  src="//t.co/i/adsct?txn_id=abcde&amp;p_id=Twitter&amp;tw_sale_amount=0&amp;tw_order_quantity=0" /></noscript>

Code from the UI:

<script>
!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);
},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='//static.ads-twitter.com/uwt.js',
a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');
// Insert Twitter Pixel ID and Standard Event data below
twq('init','abcde');
twq('track','PageView');
</script>

@michealzub

Let me check that snippet part internally and will let you know soon.

@michealzub
I spoke with the team internally and confirmed that the Web Event Tags is expected to use for the single website tag. I’d encourage you to use the snippet on the UI rather than the output from the API in this case. We’re discussing to support universal website tag as well but we don’t know when will it come at the moment. Thank you for your patience.

Thanks,
Shohei