DexterLabZ / bridge.mainnet.zenon.community

1 stars 0 forks source link

Integrate Attribute Cross-Domain + Trigger an Event #14

Open mehowz opened 1 year ago

mehowz commented 1 year ago

With discussions with sumamu, there was willingness to integrate one Attribute event into the NoM Bridge. On our end this would be configured as a cross-domain setup between zenon.org and bridge.mainnet.zenon.community domains, meaning that our user sessions would be shared from an analytical point of view. We do set the anonymizeIp value to true in order to avoid tracking IP addresses.

We've integrated the NoM Affiliate System with Attribute and into all new Zenon.Org landing pages. This means that anyone who generates a campaign link for any Zenon.Org landing page using their zenon address and promotes that campaign, will get attributed the referral commission for any traffic that ends up converting a wZNN to ZNN swap using the NoM Bridge.

In order for us to display whether a marketer's campaign generated a conversion on the NoM Bridge, we need your team to integrate 2 Attribute snippets of code, along-with an event into the wZNN -> ZNN Swap Success function.

Here are the integration instructions:

Paste this code as high in the of the page as possible:

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-TC768WT');</script>
<!-- End Google Tag Manager -->

Additionally, paste this code immediately after the opening tag:

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TC768WT"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

You can trigger the event of the google analytics by calling the gtag function that is created in the script tag, if the wZNN to ZNN swap is successful:

(window as any).gtag('event', 'attribute' /* event actions which must be 'attribute' for all events */, {
  send_to: googleMeasurement, //google measurment id
  event_category: eventCategory, //event category you want to pass
  event_label: eventLabel, //event label you want to pass
  value: eventValue, //event numerical value you want to pass (optional)
});

Here’s an example of how the event should be set:

swap_wznn_znn_success: { //your unique event id/name
 eventAction: 'attribute', //must always be 'attribute' for all events
 eventCategory: 'bridge_tokens', //event category you want to pass
 eventLabel: 'swap_wznn_znn_success', //event label you want to pass
 eventValue: $value, //if you want to pass any numerical value (optional)
}
mehowz commented 1 year ago

We could integrate this as well whenever you open source the code.