Home ยป Blog ยป Lead Generation ยป Leadshook Conversion API Setup

Contents

    This guide is written for the purpose of implementing, for a deeper understanding of how the individual elemenents work please refer to leadshook’s own article on the subject over here.

    Create the following answer fields

    fbc, fbp

    First Node Add the following scripts

    Save FBC

    <script>  
      (function check_fbq () {
        if (typeof fbq === 'undefined') setTimeout(check_fbq, 100)
        DT.grabCookie('fbc', '_fbc')
        console.log("fbc function fired [value: " + getCookie('_fbc') + "]")
      })()
    </script>

    Save FBP

    <script>
      (function check_fbq () {
        if (typeof fbq === 'undefined') setTimeout(check_fbq, 100)
        DT.grabCookie('fbp', '_fbp')
        console.log("fbp function fired [value: " + getCookie('_fbp') + "]")
      })()
    </script>

    Save eventtime

    <script>
    DT.setField('eventtime_fb', '{_c_eventtime}')
    </script>

    Save eventid

    <script>
    DT.setField('eventid_fb', '{_c_eventid}')
    </script>

    After Conversion occurs

    Fire FB Pixel

    <script>
    fbq('track', 'Lead', {
      content_name: '{_c_dt}',
      content_category: '{_c_node}',
      value: 0.50,
      currency: 'USD'
    },
       {eventID: '{eventid_fb}'}
    );
    </script>

    Before Thank You Page Fire Serverside API

    Generate Conversion API Token

    Facebook Events > Settings > Scroll to Conversion API then click generate token

    Get test ID

    Facebook Events > Test Events > Test ID

    Setup Facebook API Node

    Method: Post

    Request URL: https://graph.facebook.com/{API_VERSION}/{PIXEL_ID}/events?access_token={TOKEN}

    TIP! Please adjust as needed. We left in some hashed values for testing. E.g Gender (ge): for testing. For your payload, you MUST add a custom field like {fb_gender:lowercase|sha256}. The values below need to be updated with your custom fields. The hashed values below are there for a quick test only.

    {
        "data": [
            {
                "event_name": "Lead",
                "event_time": {eventtime_fb},
                "action_source": "website",
                "event_id": "{eventid_fb}",
                "event_source_url": "{_c_eventurl}",
                "user_data": {
                    "client_user_agent": "{_c_useragent}",
                    "client_ip_address": "{ip_address}",
                    "fbc": "{fbc}",
                    "fbp": "{fbp}",
                    "em": "{email|sha256}",
                    "ph": "{phone_number|raw|international|no_leading_plus|sha256}",
                    "fn": "{first_name:lowercase|sha256}",
                    "ln": "{last_name:lowercase|sha256}",
                    "db": "531764f38242ecae4d34116402255481859cf83552a545cad2b03268a4204f1a",
                    "ge": "62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a",
                    "ct": "6d5809aba9e26ace73438fc81a5d012738b61a5b6fc913d5100e449e72d80ee2",
                    "st": "4b650e5c4785025dee7bd65e3c5c527356717d7a1c0bfef5b4ada8ca1e9cbe17",
                    "zp": "b83c588da0c6931625f42e0948054a3ade722bfd02c27816305742ed7390ac6c",
                    "country": "9b202ecbc6d45c6d8901d989a918878397a3eb9d00e8f48022fc051b19d21a1d",
                    "external_id": "{lead_id|sha256}"
                },
                "custom_data": {
                    "currency": "USD",
                    "value": "142.52",
                    "content_name": "{_c_dt}",
                    "content_category": "{_c_node}"
                }
            }
        ],
       "test_event_code": "TEST17778"
    }

    Important remove “test_event_code”: “YOURTESTID” before you go live, this code is for testing purposes only.

    Ready to Grow Your Business?