Skip to content

WP Pixel Integration with sklepyWWW.pl

Warning

The plugin currently does not have active support.
In case of errors, we recommend integration via Google Tag Manager or manually embedding the codes on your site.

Step 1: Initialize WP Pixel in the <head>

Path: Tools > Webmaster Tools > Additional javascript code in HEAD section sklepywww1

  1. Open this tool in the panel.
  2. Paste the WP Pixel initialization code here (replace WP-PIXEL-ID with your store ID).
<!-- WP PIXEL CODE: INIT -->
<script>
  !function(d,m,e,v,n,t,s){d['WphTrackObject'] = n;
  d[n] = window[n] || function() {(d[n].queue=d[n].queue||[]).push(arguments)},
  d[n].l = 1 * new Date(), t=m.createElement(e), s=m.getElementsByTagName(e)[0],
  t.async=1;t.src=v;s.parentNode.insertBefore(t,s)}(window,document,'script',
  'https://pixel.wp.pl/w/tr.js', 'wph');
  wph('init', 'WP-PIXEL-ID');
</script>
<!-- END WP PIXEL CODE: INIT -->

Step 2: ViewProduct on the product page

Path: Tools > Webmaster Tools > Additional code on product page sklepywww2

  1. Open this tool in the panel.
  2. Paste the tracking script for “ViewProduct” here (adjusted to your variables).
<!-- WP PIXEL CODE: VIEWPRODUCT -->
<script>
function whenAvailable(name, callback) {
    var interval = 10; // ms
    window.setTimeout(function() {
        if (window[name]) {
            callback(window[name]);
        } else {
            whenAvailable(name, callback);
        }
    }, interval);
}

function test(object, value) {
    return Object.keys(object).find(key => object[key] === value);
}

function flattenObj(obj){
let flat = {}
    for(let i in obj){
       if(typeof obj[i] == 'object'){
          let flatObj = flattenObj(obj[i])
          for(let x in flatObj){
              flat[i + "." + x] = flatObj[x]
          }
      } else {
       flat[i] = obj[i]
      }
   }
return flat
}

whenAvailable("get_products_data", function(t) {
flat_categories = flattenObj(categories)

wph('track', 'ViewContent', {
    'content_name': 'ViewProduct',
    contents: [{
        id: '#PRODUCT_ID#',
        name: '#PRODUCT_NAME#',
        price: Number(Number(get_products_data(#PRODUCT_ID#).price_special).toFixed(2)),
        category: test(flat_categories, Number(get_products_data('#PRODUCT_ID#').category_id)) == undefined? undefined : flat_categories[test(flat_categories, Number(get_products_data('#PRODUCT_ID#').category_id)).split('.').slice(0,test(flat_categories, Number(get_products_data('#PRODUCT_ID#').category_id)).split('.').length-1).join('.')+".name"]
    }]
})
})
</script>
<!-- END WP PIXEL CODE: VIEWPRODUCT -->

Step 3: View, ProductList and AddToCart in <body>

Path: Tools > Webmaster Tools > Additional javascript code in BODY section

  1. Open this tool in the panel.
  2. Paste the scripts here:
  3. tracking views (ViewContent)
  4. tracking product list (ProductList)
  5. tracking add to cart (AddToCart)

sklepywww3

<!-- WP PIXEL CODE: VIEW, PRODUCTLIST AND ADDTOCART -->
<script>
    wph('track', 'ViewContent', { 'content_name': 'View' })
</script>

<script>
add_to_basket = function(products_id, quantity, id)
{
    if(quantity == 0)
    {
        if($("#add_product_overlay").length > 0)
        {
            $("#add_product_overlay").remove();

            // resume page scrolling
            wznowPrzewijanie();
        }
        return;
    }

    product = get_products_data(products_id);

        function test(object, value) {
    return Object.keys(object).find(key => object[key] === value);
}

function flattenObj(obj){
let flat = {}
    for(let i in obj){
       if(typeof obj[i] == 'object'){
          let flatObj = flattenObj(obj[i])
          for(let x in flatObj){
              flat[i + "." + x] = flatObj[x]
          }
      } else {
       flat[i] = obj[i]
      }
   }
return flat
}
flat_categories = flattenObj(categories)

    if (id || product_page || !product.with_options) {
        quantity = (quantity == undefined ? 1 : quantity);
        id = (id != undefined ? id : "");


                wph('track', 'AddToCart', {
                   contents: [{
                     id:  product.product_id,
                     name: product.name,
                     price: Number(Number(product.price_special).toFixed(2)),
                     category: test(flat_categories, Number(product.category_id)) == undefined? undefined : flat_categories[test(flat_categories, Number(product.category_id)).split('.').slice(0,test(flat_categories, Number(product.category_id)).split('.').length-1).join('.')+".name"],
                     quantity: quantity
                  }]
                });

        $.ajax({
            type: "POST",
            url: "rpc.php?action=add_to_basket",
            dataType: "json",
            data: "products_id="+products_id+"&quantity="+quantity+id,
            success: function(response){
                let error = true;
                let data = null;

                if (response != false) {
                    try {
                        data = JSON.parse(response);
                        error = false;
                    } catch (error) {}
                }

                if (!error) {
                    if(basket_redirect)
                        redirect_to_basket();
                    else {
                        $("#add_product_overlay").remove();
                        wznowPrzewijanie();

                        AddBasketData.construct(data, quantity, id);
                        add_to_basket_info();
                        refresh_cart();
                    }
                } else
                    alert(ERROR_ADDING_TO_CART);
            },
            error: function() {
                    alert(ERROR_ADDING_TO_CART);
            }
        });
    } else
        draw_add_product_form(product, quantity);
}
</script>

<script>
contents = []
keys = document.querySelector("div.listing").querySelectorAll("a[data-idproduktu]")
function flattenObj(obj){
let flat = {}
    for(let i in obj){
       if(typeof obj[i] == 'object'){
          let flatObj = flattenObj(obj[i])
          for(let x in flatObj){
              flat[i + "." + x] = flatObj[x]
          }
      } else {
       flat[i] = obj[i]
      }
   }
return flat
}
function test(object, value) {
    return Object.keys(object).find(key => object[key] === value);
}
flat_categories = flattenObj(categories)

for (i = 0; i < keys.length; i++){
id = keys[i].getAttribute("data-idproduktu")
contents.push({id: id,
                            name: get_products_data(id).name,
                            price: Number(Number(get_products_data(id).price_special).toFixed(2)),
                            category: test(flat_categories, Number(get_products_data(id).category_id)) == undefined? undefined : flat_categories[test(flat_categories, Number(get_products_data(id).category_id)).split('.').slice(0,test(flat_categories, Number(get_products_data(id).category_id)).split('.').length-1).join('.')+".name"]
   })
}
if(contents.length > 0 & window.location.pathname.includes('-c-')){
wph('track', 'ViewContent', {
    'content_name': 'ProductList',
    contents:  contents
})
}
</script>
<!-- END WP PIXEL CODE: VIEW, PRODUCTLIST AND ADDTOCART -->

Step 4: Purchase event (order completion)

Path: Configuration > Sales > Order handling: sklepywww4

Click Edit on the module Custom JavaScript: sklepywww5

  1. Open editing of this module.
<!-- WP PIXEL CODE: PURCHASE-->
<script>
ids = "#PRODUCTS_IDS_x#"
ids = ids.split('x')
contents = []
function whenAvailable(name, callback) {
    var interval = 10; // ms
    window.setTimeout(function() {
        if (window[name]) {
            callback(window[name]);
        } else {
            whenAvailable(name, callback);
        }
    }, interval);
}

function flattenObj(obj){
let flat = {}
    for(let i in obj){
       if(typeof obj[i] == 'object'){
          let flatObj = flattenObj(obj[i])
          for(let x in flatObj){
              flat[i + "." + x] = flatObj[x]
          }
      } else {
       flat[i] = obj[i]
      }
   }
return flat
}
function test(object, value) {
    return Object.keys(object).find(key => object[key] === value);
}

whenAvailable("categories", function(t) {
flat_categories = flattenObj(categories)

for(var i =0; i < ids.length; i++){
id = ids[i];
item = {id: id,
         name: get_products_data(id).name,
        price: Number(Number(get_products_data(id).price_special).toFixed(2)),
        category: test(flat_categories, Number(get_products_data(id).category_id)) == undefined? undefined :
flat_categories[test(flat_categories, Number(get_products_data(id).category_id)).split('.').slice(0,test(flat_categories,
Number(get_products_data(id).category_id)).split('.').length-1).join('.')+".name"]
}
contents.push(item)
}

wph('track', 'Purchase', {
transaction_id: "#ORDER_ID#",
value_gross: Number((#SUBTOTAL#).toFixed(2)),
shipping_cost: Number((#TOTAL# - #SUBTOTAL#).toFixed(2)),
contents: contents
});
})
</script>
<!-- END WP PIXEL CODE: PURCHASE -->

Done!

WP Pixel integration has been successfully completed 🎉
If you encounter technical difficulties, you can use integration via GTM or ask your developer for support.