Table of Contents

This is an example of Meta pixel and Fresh8 integration based on the following example https://docs.google.com/document/d/1rpbE_3YGjyUF8lcjLsNc-NLFPVGE5emzock1glXy8Wc/edit#heading=h.p0jnzxwfmugg.

Bare in mind, all integration is done via Google Tag Manager.

When integrating Facebook pixel, there are a couple required events that need to be set up:

  1. Init
  2. Pageview

Other events are optional, but the more are added, the better result can be achieved.

Please note, javascript code snippets in the screenshots were added just for display purposes. The correct code snippets are next to the screenshots and these should be pasted in Google Tag Manager.

Custom variables

In some code snippets we use

{{variable name}}

These variables represent data sent from our app. For instance, when user adds bet to betting slip, gtm-addBetToBettingSlip event is sent with some data, e.g. event UUID, market and etc… So each

{{variable}}

created represents single piece of data, which then can be used in Tags.

For custom variable list please read Custom variables section.

Triggers

Some of the Tags are using triggers. Trigger is basically and event sent from our app. We need to create a trigger for each event, and then those triggers are assigned to Tags.

For trigger list please read triggers section.

GTM Tags

Init

Set up screenshot below.

Code snippet below. Please replace 'META PIXEL ID' with your Pixel ID.

<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
// Line to enable Manual Only mode.
fbq('set', 'autoConfig', false, 'META PIXEL ID');
// FB init
fbq('init', 'META PIXEL ID');
</script>
<!-- End Meta Pixel Code -->

Pageview

Implementation screenshot:

<script>fbq('track', 'PageView');</script>

View content

<script type='text/javascript'>
  var operatorID = {{Fresh8 operatorID}}
  var eventIDS = {{Event UUIDS}}
  var url = 'https://pixel.fresh8.co/' + operatorID + '/' + eventIDS[0] + '?type=ViewContent'
  var ids = new Request(url);
    fetch(ids)
      .then(function(res) {
        return res.json();
      }).then(function(data) {
        fbq('track', 'ViewContent', {
          content_type: 'product',
          content_ids: data,
          content_name: {{Content name}}
        });
      })
       // When user uses ad blocker, request throws unhandled error. Catch prevents this. 
      .catch(function() {});
</script>

Add to cart

<script type='text/javascript'>
  var operatorID = {{Fresh8 operatorID}}
  var eventIDS = {{Event UUIDS}}
  var url = 'https://pixel.fresh8.co/' + operatorID + '/' + eventIDS[0] + '?type=AddToCart'
  var selection = {{selection}}
  var market = {{market}}
  var ids = new Request(url);
    fetch(ids)
      .then(function(res) {
        return res.json();
      })
      .then(function(data) {
        fbq(
          'track',
          'AddToCart',
          {
            content_name: {{Content name}},
            content_ids: data,
            content_type: 'product',
            contents: [{'id': selection + '|' + market, 'quantity': 1}]}
         );
      // When user uses ad blocker, request throws unhandled error. Catch prevents this. 
      }).catch(function() {});
</script>

Initiate checkout

<script>
  fbq("track", "InitiateCheckout", {
   step: 'registration_start'
  });
</script>

Lead

Code snippet below. Please replace currency 'EUR' with your currency symbol.

<script>
fbq("track", "Lead", {
  currency: 'EUR',
  value: 0,
  external_id: {{user ID}},
});
</script>

Purchase

Please replace currency with your own.

<script type='text/javascript'>
  var operatorID = {{Fresh8 operatorID}}
  var eventIDSCollection = {{Event UUIDS}}
  var eventIDSAsString = eventIDSCollection.join(',');
  var url = 'https://pixel.fresh8.co/' + operatorID + '/' + eventIDSAsString + '?type=Purchase'
  var ids = new Request(url);
    fetch(ids)
      .then(function(res) {
        return res.json();
      }).then(function(data) {
        fbq('track', 'purchase', {
        content_type: 'product',
        content_ids: data,
        currency: 'EUR',
        value: {{Amount}}
        });
      })
      // When user uses ad blocker, request throws unhandled error. Catch prevents this. 
      .catch(function() {});
</script>

Login

<script>
fbq("trackCustom", "Login", { account: {{user ID}} });
</script>

Complete registration

Please replace currency with your own.

<script>
  fbq("track", "CompleteRegistration", {
    currency: 'EUR',
    external_id: {{user ID}},
    value: {{Amount}} 
  });
</script>

Subscribe

Please replace currency with your own.

<script>
  fbq("trackCustom", "Subscribe", {
    value: {{Amount}},
    currency: 'EUR',
    external_id: {{user ID}}
  });
</script>

Data Layer Variables

To create data variables:

{{Fresh8 operatorID}}

Do not forget to replace the value field with correct Operator ID.

{{Event UUIDS}}

{{Content name}}

{{selection}}

{{market}}

{{user ID}}

{{Amount}}

{{depositsCount}}

More information about other possible data layer variables can be found here

https://wiki.advbet.com/admin/online-platform-cms/google-events#events-and-their-data

Triggers

Bare in mind, that event names in the screenshots might be out of date. For up to date event names please visit this page: https://wiki.advbet.com/admin/online-platform-cms/google-events?s[]=google&s[]=tag&s[]=manager#events-and-their-data-gtm

Pageview

Initiate Checkout

Registration finished

Purchase

Login

First deposit success

Subsequent deposit success

Add to slip event