# Google Tag Manager Integration

To install Backtracks Attribution in Google Tag Manager, just follow the steps below. If your Shopify theme happens to have a custom method to add third-party JavaScript, ask your Shopify administrator or developer to adapt these steps to your theme or custom method.

# Steps

# Add New Tag

In the Google Tag Manager tag configuration area, select Add New Tag for the workspace.

Google Tag Manager Add New Tag

# Add Custom HTML Tag

Choose a Custom HTML as the tag type.

Google Tag Manager Custom HTML Tag

# Copy and Paste Code

Copy and paste the install script into the HTML code input box. Be sure to replace "YOUR BT KEY" with your actual key.

Google Tag Manager Custom HTML Copy and Paste

# Select Trigger

Select the trigger that should run the code, i.e. All Page Views. If you have specific triggers, those may be tied to events that Backtracks Attribution should track.

Google Tag Manager Choose Trigger

# Enable Tag

Finally, save and publish the changes and that's it!

Google Tag Manager Final Preview and Save

# Conversion Events

To record conversion events like lead, purchase, etc. you will need to ensure that the Backtracks Attribution script is included on the page before running any code to record the event(s). Example events can be seen here.

<script>
  // START: INSTALL
  // Note: The Backtracks Attribution install script will only run once per page even if called multiple times.

  (function(b,a,c,k,t,r,s,f){b['BacktracksAttributionName']=r;b[r]=b[r]||function(){
  (b[r].q=b[r].q||[]).push(arguments)},b[r].l=1*new Date();s=a.createElement(c),
  f=a.getElementsByTagName(c)[0];s.async=1;s.src=k;f.parentNode.insertBefore(s,f);
  b['BacktracksAttributionConfig']=t
  })(window,document,'script','https://c.backtracks.fm/bt-attribution.min.js',
  {key: 'YOUR BT KEY'},'bta');

  // END: INSTALL 

  // Use any GTM (Google Tag Manager) variables that you have set up that may be appropriate
  bta("purchase", {
    transactionId: "{{ gtm_order_id_variable }}",
    value: {{ gtm_order_price_variable }},
    currency: "USD" 
    // ...
  });
</script>