This article is also available in:
You can integrate Twitter conversion tracking ID into your online store to help you understand more about customer behavior and the traffic source. This tag collects data about how customers are using your online store pages, so that you can more effectively plan your ad campaigns to find new customers.

In this section
A. Get your Twitter conversion tracking ID
B. Install the Twitter Pixel ID on ShopBase store

A. Get your Twitter conversion tracking ID

Log into your Twitter account, go to Twitter Ads in tab More.

At the top of the screen, click Tools > Conversion tracking and press Create new conversion event by following step 3 of this guideline

To get the Twitter Pixel ID, click on View code and installation instructions.

Copy Twitter Pixel ID from the line that resembles “twq(‘init’,‘twitter_pixel_id’);”

B. Install the Twitter Pixel ID on ShopBase store

From your ShopBase admin site, go to Online Store > Preferences

Scroll to the Additional scripts > Head section

Paste this scripts.

const twitterId = "o48hp" // Insert Twitter Pixel ID

window.sbsdk.ready(function() {
window.sbsdk.cart.onAdd(function(payload) {
let cart = window.sbsdk.cart.get()
let product_added = cart.items.find(item => item.variant_id === payload.variant_id)
twq('track', 'AddToCart', {
value: product_added.price,
currency: cart.currency,
order_quantity: String(payload.qty),
let isTracked = false; {
if(context.type !== 'process_checkout') {
isTracked = false;
if(context.type === 'process_checkout' || context.type ==='checkout') {
if(!isTracked) {
let cart = window.sbsdk.cart.get()
let cartItem = {
return item = {
'id': item.product_id,
'quantity': item.qty,
'item_price': item.total_line_with_discount_price,
twq('track', 'InitiateCheckout', {
contents: JSON.stringify(cartItem),
currency: cart.currency,
value: String(cart.subtotal_price),
num_items: String(cart.item_count)
isTracked = true
switch (context.type) {
case 'home':
case 'cart':
case 'collection':
case 'collections':
case 'product':
case 'post_checkout':
// Inject code tracking at thank you page here
let order = window.sbsdk.checkout.getOrder()
let collection_titles = []
if(order.items.length > 0 ) {
for(let x in order.items) {
let collections = order.items[x].collections
for(let y in collections) {
collection_titles[y] = collections[y].title
let line_items = {
return item = {
'product_category': collection_titles,
'product_name': item.product_title,
'product_id': item.product_id,
'product_quantity': item.qty,
'product_price': item.item_price,
let qtyBlock = document.getElementsByClassName('checkout-product-thumbnail__quantity');
let qty = 0
for (let i = 0; i < qtyBlock.length; ++i) {
qty += parseInt(qtyBlock[i].innerHTML)
let totalPrice = document.getElementsByClassName('payment-due__price')[0].innerHTML
totalPrice = totalPrice.substring(1)
totalPrice = totalPrice.substring(0, totalPrice.length - 3)

twq('track', 'Purchase', {
order_id: String(,
value: String(totalPrice),
order_quantity: String(qty),
currency: window.sbsdk.cart.get().currency,
line_items: JSON.stringify(line_items)


Replace o48hp in Line 2 with your Twitter conversion tracking ID

Press Save and you are done.


After adding Twitter conversion tracking ID into ShopBase, you must create create an Ad campaign in your Twitter Ads account in order to receive data about your customers by following this instruction Campaign creator guide.

Related articles

Set up Facebook Pixel IDs and Conversions API in ShopBase
Set up Google Analytics
Track Google Ads Conversions with ShopBase
Install Bing Ads Conversion Tracking on ShopBase
Install Hotjar Tracking Code
Install the Pinterest tag on ShopBase
Add codes of other tracking tools to ShopBase store
Was this article helpful?
Thank you!