# Add pixel to shoplazza website

Go to Shoplazza Admin 》-【Application Market】-【Custom Code Embed】

shoplazza1.jpg

First name the code snippet, then paste in the snippet you need to add, select the client and trigger page, and where to place the code.

shoplazza2.jpg

Add the following code

Replace <MKQ_PIXEL_ID> with the pixelid of your site

<script type="text/javascript">
  !function(w,o,s,r,p,k,e){if(w.mkq){return}p=w.mkq=function(){p.invokeFunc?p.invokeFunc.apply(p,arguments):p.qu.push(arguments)};if(!w._mkq){w._mkq=p}p.push=p;p.qu=[];k=o.createElement(s);k.async=!0;k.src=r;e=o.getElementsByTagName(s)[0];e.parentNode.insertBefore(k,e)}(window,document,"script","//pixeltrack.clientgear.com/mkq.min.js");
  mkq('init', '<MKQ_PIXEL_ID>');
  mkq('track', 'PageView', {
		title: document.title
	});



  $(function () {
    var currency_code = window.SHOPLAZZA.currency_code || "USD";

    // 产品页面
    $(document.body).on('dj.viewContent', function (e, data) {
      mkq('track', 'ViewContent', {
        value: data.product.price,
        currency: currency_code,
        content_name: data.product.meta_title,
        content_type: 'product',
        content_ids: [data.product.id]
      });
    });
    // 加入购物车页面
    $(document.body).on('dj.addToCart', function (e, data) {
      mkq('track', 'AddToCart', {
        value: data.product.price,
        currency: currency_code,
        content_name: data.product.meta_title,
        content_type: 'product',
        content_ids: [data.product.id]
      });
    });


    // 初始化支付
    $(document.body).on('dj.initiateCheckout', function (e, data) {
      mkq('track', 'InitiateCheckout', {
          value: data.prices.total_price,
          currency: currency_code,
          content_ids: data.line_items.map(function(item) {
              return item.product_id
          }),
          num_items: data.line_items.length
      });
    });


    // 完成购买
    $(document.body).on("dj.purchase", function (e, data) {
      mkq('track', 'Purchase', {
          value: data.prices.total_price,
          currency: currency_code,
          order_id: data.id,
          content_ids: data.line_items.map(function(item) {
              return item.product_id
          }),
          content_type: 'product',
          num_items: data.line_items.length
      });
    })
  })
</script>