Using Twitter Pixel with Google Tag Manager on Shopify
If you're using Google Tag Manager and the TrackPixel.app to manage tags for your Shopify website, you can add your Twitter Pixel to your Google Tag Manager account to measure and optimize the results of your Twitter advertising on Shopfiy.
Follow these instructions to install the Google Tag Manager pixel on your Shopify store.
To access the tag code within your Twitter Ads account, go to the Tools dropdown in the top navigation bar and choose Conversion Tracking. You’ll see a prompt to get started with generating your website tag.
Once you click “Generate website tag,” you’ll see a screen showing the code for your tag along with setup details.
Instead of copying and pasting the whole code, you’ll want to look for the unique 5-character identifier Twitter uses for each tag. You’ll find this in the following portion of code (the area shown masked in red in the screenshot):
twq('init',’abcde’);
The portion in single quotes following ‘init’ is your Twitter ID; copy this and hang onto it for Google Tag Manager. Now, let’s move to creating your tag in GTM.
Creating the Twitter Tag in GTM
Access the GTM container for your site and create a new tag. Choose “Twitter Universal Website Tag” as the tag type.
Now, paste the unique ID you copied from the code into the “Twitter pixel ID” field. Leave “PageView” selected as the tag event. Finally, choose “All Pages” as the trigger for your tag. Save and publish the tag live.
Within a few hours, the Twitter tag should start registering site visits. You can verify that the tag is live by visiting Tools > Conversion Tracking and checking the tag status.
Next, let’s move on to tracking a custom event in Twitter.
Creating a Custom Twitter Tag
While you can define conversions and audiences by URL rules using the universal tag, you may want to track additional events that can’t be defined using a URL. As an example, let’s set up a tag to track PDF downloads.
Go to Tools > Conversion Tracking and select “Create a New Conversion Event.” We’ll give it a unique name, choose “Download” as the type of conversion, and select “Use a single website tag.” Note that you can also choose to create a tailored audience (essentially a retargeting audience) based on users who trigger a certain event.
Finally, we’ll agree to terms and save the conversion event. You’ll be presented with a code for the event; this time, you should copy and paste the entire code.
Now, create a custom HTML tag in Google Tag Manager. (Side note: the Twitter GTM template includes custom events as options, but it appears that the manually created tag is Twitter’s preferred route for tracking events for now). Paste the custom event code from Twitter.
Finally, add a trigger for your desired action. In this case, we set up a PDF Download trigger that includes any clicks on URLs containing a .pdf extension. Save your tag, publish it in GTM, and watch the conversion data in Twitter to be sure it’s tracking properly.
Track Your Twitter Ads Performance
With GTM at your side, you can easily add Twitter pixels to your site both to create audiences and track custom conversion events. Now, it’s time to deploy your campaigns, build your audiences, and watch the data gather!