How to track Paid Acquisition Campaigns with Pico

When running paid acquisition to direct new sign-up or subscribers to your site through Facebook or Google, it's possible to track the effectiveness of the campaign.

Measure an accurate return on ad spend (ROAS) from your campaigns.

Pico records UTM parameters (source, campaign, medium, content) that were included on a users initial load on your site, for both sign up and payment events.

This data is stored in the Pico CRM and is available in the CSV export, which can allow you to identify the source of conversions. It is possible for the signup UTM and payment UTM to be different, if they occurred on different user sessions.

Firing Conversion Events on Remarketing Pixels

For acquisition strategies that support changing live campaigns based on conversion events, e.g. those that stop targeting users that have already subscribed to Pico through the campaign, it's possible using additional javascript onsite.

This is an advanced integration, and requires javascript development, though we have a code example below. This relies on Signals, to identify when site visitors have converted to registered contacts or paying subscribers, in combination with a browser cookie to only send the conversion event once. 

  1. You'll need to create an element that has the PicoSignal class, in the code snippet's example, this is on a div.
  2. Add the code snippet below to your site. In this example, both Facebook and Google conversion tracking code is shown. Others can be included in the fireTrackingEvents() method. To track events against Google Analytics, you'll need to have GA code installed on your site elsewhere. Where it says {your-pixel-id-goes-here} within the Facebook code, replace with your pixel id from Facebook as defined:
    https://developers.facebook.com/docs/facebook-pixel/implementation#base-code

var adCampaignPicoHandler = function(){
    var REGISTERED_EVENT_CAPTURED = "ad-reg-event-captured";
      var PAID_EVENT_CAPTURED = "ad-paid-event-captured";
      function setCookie(name,value,days) {
        var expires = "";
        if (days) {
          var date = new Date();
          date.setTime(date.getTime() + (days*24*60*60*1000));
          expires = "; expires=" + date.toUTCString();
        }
        document.cookie = name + "=" + (value || "")  + expires + "; path=/";
      }
      function getCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
          var c = ca[i];
          while (c.charAt(0)==' ') c = c.substring(1,c.length);
          if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
      }
      function fireTrackingEvents(){
         fireFBevent(event);
         fireGAevent(event);
         //Other Tracking events can go here.
      }
     function fireGAevent(){
        ga('send', 'event', event);
      }
      function fireFBevent(){
       !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');
       fbq('init', '{your-pixel-id-goes-here}');
       fbq('trackSingleCustom', '{your-pixel-id-goes-here}', event);
      }
      var element = document.querySelector('div.PicoSignal');
      var event = null
      var observer = new MutationObserver(function(mutations) {
        var hasSentRegistered = getCookie(REGISTERED_EVENT_CAPTURED);
        var hasSentPayment = getCookie(PAID_EVENT_CAPTURED);
        mutations.forEach(function(mutation) {
          if (mutation.type == "attributes" && mutation.attributeName == "data-pico-status") {
            if(element.getAttribute("data-pico-status") == "registered" && !hasSentRegistered){
            event = "Registered"
            fireTrackingEvents(event);
              setCookie(REGISTERED_EVENT_CAPTURED,1,3650)
            }
            else if(element.getAttribute("data-pico-status") == "paying" && !hasSentPayment){
             event ="Paying"
             fireTrackingEvents(event);
              setCookie(PAID_EVENT_CAPTURED,1,3650)
            }
          }
        });
      });
      observer.observe(element, {
        attributes: true
      });
    }
   
    window.addEventListener('pico.loaded', adCampaignPicoHandler)
    adCampaignPicoHandler()

For help setting up a Facebook or Google campaign to direct more traffic to your site, please reach out to Pico Support and we'll put you in contact with our partners.

Did this answer your question?