Understanding and Configuring Partner Attribution Referral Links

    Referral Links

    When a customer clicks on a partner link, Magentrix appends two query parameters to the URL the customer lands on. The two parameters are:

    • Magkey: a Unique session ID that is created to track customer session.
    • Magpk: a unique ID associated with the partner, this value is the partner’s CRM contact ID value.

    The link that the partner copies:

    http://partners.magentrix.com/referral/refer/4327489234723

    Forwarded to the actual landing page (What you configure in Magentrix):

    https://landing.magentrix.com/page1?utm_campaign=cam1&utm_source=youtube

    Final Link Generated by Magentrix:

    https://landing.magentrix.com/page1?utm_campaign=cam1&utm_source=youtube&magpk=23432423&magkey=2323423432

    The installed JavaScript snippet will consume the URL parameters and create first-party tracking on the customer browser. This tracking script does not store any information about the customer and only keeps partner tracking information.

    Magentrix PartnerTrack.JS

    Note: You need to whitelist the URL of the website or landing pages that you wish to deploy Magentrix PartnerTrack on.

    • Include the script on the page or the entire website.
    • On the form page, you must pass the customer info into the script and hook the script to the form submit event.

    In the Setup menu, copy the script code and paste it into the head tag of your website (preferably deployed to all pages). Add the following code to the pages that contain forms so that the form information is passed to Magentrix.

    <script>
        function onInitPartnerTracker(tracker) {
            document.getElementById("btnSubmit").addEventListener("click", function(e) {
           tracker.trackSignup({
                name: document.getElementById("customer_name").value,
                              email: document.getElementById("customer_email").value,
                              customerKey: document.getElementById("customer_email").value,
                              product: document.getElementById("product").value,
                              LeadSource: "Partner Referral"
                    });
            });
        }
        </script>

    When a customer fills out the form and provides their contact information, you need to pass that information to PartnerTrack JS.

    “onInitPartnerTracker” function is called by Magentrix PartnerTrack once the script is loaded and is ready. At this time you can bind to the click event of the primary call to action button to pass the customer info to Magentrix. Use the object passed to the function to call “trackSignup” and pass the signup information to PartnerTrack.

    • Name: the customer’s name (First name <space> Last name)
    • Email: the customer’s email address
    • Customer Key: This is a customer’s unique identifier, of course, it can be the email value as well.

    Name, email and customerKey are mandatory fields and should be provided.
    You can pass any other data you wish to be populated into the CRM Lead.
    Another way to access the PartnerTrack API is to use a global variable called “mgxPartnerTrack”.


    It is recommended that you populate a specific lead source for partner referrals to make it easier to track the partner referrals in your CRM.

    <html> 
        <head> 
          <title>A-Pear-antly Great Delivery</title>
          <link href="style.css" rel="stylesheet" />
          <!--PartnerTrack Code Goes here -->   
                <script>...</script>
     </head> 
      <body> 
        <form id="sign-up"> 
          <label for="name">Your name</label> 
          <input id="name" type="text" name="name" id="customer_name" />
       <label for="email">Your email:</label> 
          <input id="email" type="email" name="email" id="customer_email" />
       <label for="product">Product:</label>
       <input id="product" type="text" name="product" required/> 
         <input type="submit" id="submit-btn" value="Submit" /> 
    
         <!-- code for calling partner track -->
         <script>
         ...(JavaScript Above)
      </script>
    </form> 
    </body> 
    </html>

    Tracking in Magentrix Backend

    Magentrix has an entity called: “Referral” which captures:

    Field NameType
    Customer KeyText
    Unique KeyText
    Fingerprint IDText
    Lead NameText
    EmailEmail
    User AgentText
    IP AddressText
    PartnerLookup(User)
    CampaignText
    ContentText
    MediumText
    TermText
    SourceText

    A Lead is created in the CRM and assigned to that campaign.

    Embed tracking in HubSpot Forms

    If you use embed HubSpot forms or use HubSpot pages, you'll have to embed custom HTML/CSS code to:

    • Embed the tracking snippet code discussed in the above step setup process
    • Write JavaScript that can access the underlying DOM elements on your HubSpot forms, to populate values into PartnerTrack signup data.

    Below is a sample code to build the integration with HubSpot:

    <script>
    
        function registerSignup(e) {
            //In this scenario, we retrieve form elements using their name attribute. Since HubSpot Forms occasionally randomize their IDs, relying on the name attribute provides a more dependable approach.
            e.preventDefault();
            console.log('Reached registerSignup()');
        
        mgxPartnerTrack.trackSignup({
             name: document.querySelector('input[name="firstname"]').value + " " + document.querySelector('input[name="lastname"]').value,
             email:  document.querySelector('input[name="email"]').value,
             customerKey: document.querySelector('input[name="email"]').value,
             product : document.querySelector('input[name="product"]').value,
             LeadSource: "Partner Referral"
        });
         }
    
        //In this instance, the form is not embedded within an iFrame, allowing us to reach the form's DOM element and set up an event listener.
        var formReference = document.getElementsByClassName('hs-form')[0];
    
        // In rare events where the DOM element isn't reachable at the time
        // this script executes, we wait a couple seconds before attempting
        // again:
        if (!formReference) {
            console.log('Form not found yet, waiting 2 seconds...')
            // Set a time delay to capture the field afterwards:
            setTimeout(function() {
                formReference = document.getElementsByClassName('hs-form')[0];
                formReference.addEventListener("submit", function(e) {
                    console.log('PT Signup');
                    registerSignup(e);
                });
            }, 2000);
        } else {
            formReference.addEventListener("submit", function(e) {
                console.log('PT Signup');
                registerSignup(e);
            });
        }
    
    </script>
    

    Marketo Forms

    Marketo generates their signup forms using JavaScript. When you want to use a Marketo Form along with Magentrix PartnerTrack you need to combine the two scripts together.
    First, you need to copy/paste the Magentrix PartnerTrack script into the page (if it is not already included in the whole website), then you can use the following sample to update the page and pass customer data from the Marketo form to Magentrix PartnerTrack script.

    // Please update values appropriately.
    // See: https://developers.marketo.com/javascript-api/forms/api-reference/
    MktoForms2.loadForm("//your-base-url.marketo.com",
       "your_munchkin_id", 
          12, 
          function(form) {
        // Add an onSubmit handler
        form.onSubmit(function(){
            // Get the form field values
            var vals = form.vals();
            // Set customer data object in PartnerTrack:
            mgxPartnerTrack.trackSignup({
            name: vals.Name,
            email: vals.Email,
            customerKey: vals.Email,
            product: vals.Product
        });
              
                  });
    });

    Magentrix Form Layout

    In order to use the Magentrix Form layout (on Lead) as a referral page, you need to turn off the Lead generation feature of the tracking script and allow the form itself to generate the lead record.
    The only requirement is to include a “Hidden” field that passes the partner contact ID to the form and allows the Lead record to be associated with the partner contact information.

    Note: Make sure the form has a default value for “Lead Ownership” picklist and it is set to “Partner”.

    <input type="hidden" name="CRM Partner Contact Lookup Name" id="partnerContact"/>

    * Name of field in different CRM environments:

    • Native = PartnerContactId
    • Salesforce = MagentrixOne__PartnerContact_mgtrx__c

    Script for form submission:

    function onInitPartnerTracker(tracker) {
       $("#partnerContact").val(mgxPartnerTrack.getPartnerKey());
       $(".btns-block .btn-primary").click(function(e) {
           tracker.trackSignup({
                name: document.getElementById("customer_name").value,
                              email: document.getElementById("customer_email").value,
                              customerKey: document.getElementById("customer_email").value
                    });
            });
        }

    Accessing Partner Key

    Use the “getPartnerKey” method to access the Partner Contact ID and populate it on the Magentrix Partner Contact lookup in the CRM to attribute the deal to the partner properly.
    Ensure to populate the “Lead Ownership” field with “Partner”.
    You can safely use “mgxPartnerTrack” object on the page. This object is accessible once the Partner Track script is loaded.

    var partnerContactId = mgxPartnerTrack.getPartnerKey();
    « Previous Article


    0.0 (0)


    Comments

    No records to display

    Subscription
    Follow Knowledge posts
    Please enter your email address to subscribe:

    Email:
    Subscribe
    Follow us on Twitter