PICKZEN
  • FAQ
  • Security in Pickzen
  • Builder
    • Builder Overview
    • Questions
      • Types and layouts
      • Display settings
      • Styling the text
      • Slide settings
      • Admin names
      • Slide help
      • Feedback slide
      • End slide
        • Number of outcomes
        • Forget results
        • Automatic redirect
        • Recommending content
      • Skip Logic
        • Branching controlled by slides
        • Branching controlled by tree
    • Products
      • Selecting products
      • Managing products
    • Linking
      • Linking choices to products
    • Install
      • Notification
      • Link
      • Button
      • Embedded
    • Lead Generation
      • Lead capture before recommendation
      • Receiving leads by e-mail
      • Sending e-mails to new leads
        • Adding customized data to e-mails
    • Advanced
      • Product attributes
      • Features table
        • Features from linking
        • Features from attributes
        • Smart texts
      • Insertable texts
        • User answers
        • Response based texts
      • Slots
  • Analytics
    • A/B Tests
      • Launching an A/B Test
      • Reviewing A/B test results
    • Insight panel
      • Overview
      • Responses
      • Leads
    • Parameters tracking
    • Sales tracking
  • Integrations
    • Your website
      • Pickzen Code
        • Installing the Pickzen Code in Shopify
        • Installing the Pickzen Code on any website
      • Add to cart
      • Add all to cart
    • MailChimp
    • Klaviyo
    • HubSpot
    • Zapier
    • Recharge
      • Recharge v1
      • Recharge v2
    • Product Feeds
    • Google Analytics
    • Facebook
  • Guides
    • Facebook/Instagram retargeting
    • HubSpot guide
    • MailChimp guide
    • Klaviyo guide
    • No-Code
      • Builder
        • Aliases
        • Tables
          • Executable tables
          • Data tables
          • Cell types
        • Settings
        • Simulation
      • Functions
        • ADDTO
        • CONCAT
        • EMPTY
        • EVALTABLE
        • EXTRACT
        • FIRST
        • FLAT
        • LOG
        • NTH
        • PERSONALITY
        • PRESCRIBE
        • PRESCRIBESLOTS
        • PROPERTY
        • RANK
        • RECIDS
        • RECGROUP
        • RECSKUS
        • REFINE
        • REMOVEFROM
        • SECOND
        • SLOTS
        • SPLIT
        • TABLEVALUE
        • TRUNC
      • Tutorials
        • Prescription Rules + Taglines
        • Calculator
  • Design System
    • Enabling the DS
    • The builder
      • Preview panel
      • Components panel
      • Properties panel
    • Properties
    • Variants
    • Properties values
      • Parametrization
      • References
      • Deferred actions
    • Components
      • [Base]
      • Button
      • Collapsable
      • Container
      • CoverSlide
      • Deck
      • Dropdown
      • EndFormSlide
      • EndSlide
      • FeedbackSlide
      • FormMapper
      • FormSlide
      • Grid
      • HTML
      • Icon
      • Image
      • InputDate
      • InputNumber
      • InputText
      • Label
      • Link
      • Product
      • ProgressBar
      • QuestionSlide
      • Repeater
      • Separator
      • SlideRenderer
      • Specs
      • TextArea
    • Views
    • Editor settings
    • Accesibility
    • Interceptors
    • HowTo
      • Show a variant programmatically
      • Use CSS in custom component
  • Administration
    • Managing accounts
      • Inviting collaborators
      • Requesting access
    • Copying pickzens between accounts
    • Replacing pickzens
    • Recovering versions
  • Developers
    • Developers panel
      • CSS customization
      • JavaScript customization
    • JavaScript API
      • Hooks
      • HOWTOs
        • How to add results
        • How to get the answers
        • How to decorate products
        • Escaping the iframe
    • REST API
      • API rate limit
      • Assistants resource
      • Responses resource
    • SDK
      • Documentation
        • Engine
        • Slide
        • CoverSlide
        • QuestionSlide
          • QuestionOption
        • FeedbackSlide
        • FormSlide
          • FormField
            • SelectorField
            • SelectorFieldOption
            • ImageField
        • EndSlide
          • Result
      • HOWTOs
        • Populate custom dropdown
Powered by GitBook
On this page
  • Shopify
  • Shopify + Recharge v1
  • Shopify + Recharge v2
  • Other platforms
  1. Analytics

Sales tracking

PreviousParameters trackingNextYour website

Last updated 2 years ago

Sales can be tracked by Pickzen once configured. Pickzen will differentiate between direct sales and indirect sales:

  • Direct sales: Sales of products that have been recommended by Pickzen.

  • Indirect sales: Sales of products not recommended by Pickzen. This is important in Assistants that don't recommend products, for example, a Sizer. Pickzen will claim an indirect sale only if the customer previously completed an Assistant.

The Sales module is disabled by default and it is only eligible for certain accounts. Write to us to evaluate your case.

Shopify

In order to track sales from products purchased in Shopify, log into your Shopify store and go to Settings / Checkout / Order processing / Additional scripts and add the following code:

{% if first_time_accessed %}<script>var pzOrderId={{order.order_number}};if(pzOrder={{checkout.order.line_items|json}} || {{order.line_items|json}},pzOrder){for(var pzProducts=[],pzI=0;pzI<pzOrder.length;pzI++){var line=pzOrder[pzI],gId=(line.product_id||line.product.id).toString();pzProducts.push({id:line.variant_id.toString(),gId:gId,price:parseFloat(line.price),quantity:line.quantity})}var pzTimer=setInterval(function(){window.pzIntegrationLoaded&&(clearInterval(pzTimer),window.pzConvertionTracker.notify(pzProducts,{order:pzOrderId}))},1e3)}</script>{% endif %}

Example:

Shopify + Recharge v1

In order to track subscription sales from Recharge v1, first ensure you followed the configuration steps for Shopify. Once done, open the Recharge app in your Shopify store, and click on Checkout:

Then, add the following code to the Thank you page, replacing first the XXXXXXXX code with your userId:

<script async src="https://admin.pickzen.com/client/id/XXXXXXXX"></script>

{% if first_time_load %}<script>function parseHtmlEntities(r){return r.replace(/&#([0-9]{1,3});/gi,function(r,t){var e=parseInt(t,10);return String.fromCharCode(e)})}var pzOrderId={{order_number}},pz_products=[];{% for item in line_items %}pz_products.push({id:"{{item.variant_id}}",gId:"{{item.product_id}}",price:{{item.price}},quantity:{{item.quantity}}});{% endfor %}var pzTimer=setInterval(function(){var r;window.pzIntegrationLoaded&&(clearInterval(pzTimer),(r=parseHtmlEntities("{{attributes.pzRechargeData}}"))&&(r=JSON.parse(r)).forEach(function(r){pzConvertionTracker.notify(pz_products,{order:pzOrderId},2,JSON.stringify(r))}))},1e3);</script>{% endif %}

Example:

You can get your userId in Integrations / Your Website / Pickzen Code

Finally, you need to add this code into Integrations / Your Website / Developers / Integration code:

window.pickzen.onCompletion = function(code, products) {
  jQuery.getJSON('/cart.js', function(cart) {
    var rd;

    if (cart.attributes.pzRechargeData) {
      rd = JSON.parse(cart.attributes.pzRechargeData);
    } else {
      rd = [];
    }

    var data = window.pickzen.utils.getByKey(rd, 'code', code);
    if (!data) {
      data = {
        code: code,
        ct: code + ',0:0',
        pt: []
      };
      rd.push(data);
    }

    products.forEach(function(p) {
      if (!window.pickzen.utils.getByKey(data.pt, 'id', p.id)) {
        data.pt.push(p);
      }
    });

    jQuery.post('/cart/update.js', "attributes[pzRechargeData]=" + JSON.stringify(rd));
  });
};

Shopify + Recharge v2

In order to track subscription sales from Recharge v2, simply ensure you followed the configuration steps for Shopify.

Other platforms

Go to Integrations / Your site and enter the fragment of the page that corresponds with your confirmation URL:

Below, in the Code to get purchased products, you can enter your custom JavaScript code to fetch the purchased products and send them to Pickzen:

var pzOrderId = orderId;
var pzProducts = products; 

var pzTimer = setInterval(function() {
    if (window.pzIntegrationLoaded) {
        clearInterval(pzTimer);
        window.pzConvertionTracker.notify(pzProducts, {
            order: pzOrderId
        });
    }
}, 1000);