How to add the Script in Lightspeed


Part 1: How to install the script

Part 2: How to install the setEmail script

Part 3: How to install the setEmail script within Klarna Checkout


Part 1: How to install the script

  1. Copy the snippet below and replace PUBLIC_ID with your actual Public ID (How to find your Public ID)
    <!-- Start ProfitMetrics - snippet - (v1) -->
    <script>
    window.profitMetrics = {
    pid: 'PUBLIC_ID',
      emailInputSelector: '#gui-form-customer-email, #gui-form-email',
    }
    </script>
    <script src="https://cdn1.profitmetrics.io/PUBLIC_ID/bundle.js" defer></script>
    <!-- End ProfitMetrics - snippet - (v1) -->
  2. Click "Instellingen"
    Edit Javascripts and Tracking Code in Website Settings - Step 2

  3. Click "Web-extras"
    Edit Javascripts and Tracking Code in Website Settings - Step 3
  4. Paste the code in "Custom javascript" > "Javascript"
    Edit Javascripts and Tracking Code in Website Settings - Step 7
Ensure the status is "Enabled"
Edit Javascripts and Tracking Code in Website Settings - Step 14

Part 2: How to install the setEmail script

  1. Copy this snippet
    <!-- Start ProfitMetrics - setEmail - (v1) -->
    <script>
    function _pm_tryemailorderconfirmation() {
    if( null != window.profitMetrics && null != window.profitMetrics.setEmail && typeof window.profitMetrics.setEmail === 'function' ) {
    window.profitMetrics.setEmail( '' );
    } else {
    setTimeout( _pm_tryemailorderconfirmation, 500 );
    }
    }
    _pm_tryemailorderconfirmation();
    </script>
    <!-- End ProfitMetrics - setEmail - (v1) -->
  2. Paste the "setEmail" script in "TRACKING" > "Tracking code"
    Edit Javascripts and Tracking Code in Website Settings - Step 12
  3. Ensure the status is "Enabled"Edit Javascripts and Tracking Code in Website Settings - Step 16

Part 3: How to install the setEmail script within Klarna Checkout

  1. Copy the snippet below
    window._klarnaCheckout(function(api) {
      api.on({
           'change': function(data) {
                profitMetrics.setEmail( data.email );
                 window.dataLayer = window.dataLayer || [];
                 dataLayer.push({
                        'event': 'klarnaCheckout',
                        'klarnaCheckout': {'email': 'data.email'},
                 });
           }
      });
    });
  2. Paste it inside of the Klarna checkout <iframe>
  3. If your Hybrid Server-side Universal Integration Script is set up through Google Tag Manager you will need to create a DataLayer variable for klarnaCheckout.email and insert it in the Tag.