Twenga pixel

Download Twenga pixel script

As a requirement, the pixel below have to be triggered unconditionally, retrieving data whichever the traffic source is. Please, note: The pixel will collect only item-based performance metrics. We do not store user level information

The Twenga pixel is an analytics tool that consists of a code that you can put on your website.

It must be installed on 2 types of pages :
  1. Product page
  2. Sales Confirmation page
For the 2 types of pages :

Configuration for the product page

Format and examples of values :
  • %host% (Character string): Value reported by your account manager. Ex: twenga.my-ecommerce-site.com
  • %master_site_id% (Integer): Value communicated by your account manager. Ex: 12548
  • %item_feed_reference_id% (Character string): Product reference as it appears in the feed. Ex: 381223798UT207GR
  • %item_feed_variant_id% (Character string): Product variant identifier as it appears inthe feed. Optional value if it is not used in the feed. Ex: 123ABC. Leave carácter string empty if there is not variant for thisproduct or if the structure of your catalog doesn’t have variant at all.
  • %currency_iso_code% (Character String): ISO 4217 currency code. Ex: EUR
  • %country_iso_code% (Character string) : ISO 3166-1 alpha-2. Optional value. Ex: FR. Please send empty string if the parameter is not available.
  • %price_including_taxes% (Decimal): Price including VAT, excluding shipping costs. A "." must be used as separator of the decimal part. Ex: 60.00
<script type="text/javascript">function twgb646(t){return t>64&&t<91?t-65:t>96&&t<123?t-71:t>47&&t<58?t+4:43===t?62:47===t?63:0}function twg6b64(t){return t<26?t+65:t<52?t+71:t<62?t-4:62===t?43:63===t?47:65}function twgb64ea(t){for(var e=2,r="",n=t.length,o=0,g=0;g<n;g++)e=g%3,g>0&&4*g/3%76==0&&(r+="\r\n"),o|=t[g]<<(16>>>e&24),2!==e&&t.length-g!=1||(r+=String.fromCharCode(twg6b64(o>>>18&63),twg6b64(o>>>12&63),twg6b64(o>>>6&63),twg6b64(63&o)),o=0);return r.substr(0,r.length-2+e)+(2===e?"":1===e?"=":"==")}function twgs2a(t){for(var e,r,n=t.length,o=0,g=0;g<n;g++)o+=(r=t.charCodeAt(g))<128?1:r<2048?2:r<65536?3:r<2097152?4:r<67108864?5:6;e=new Uint8Array(o);for(var a=0,i=0;a<o;i++)(r=t.charCodeAt(i))<128?e[a++]=r:r<2048?(e[a++]=192+(r>>>6),e[a++]=128+(63&r)):r<65536?(e[a++]=224+(r>>>12),e[a++]=128+(r>>>6&63),e[a++]=128+(63&r)):r<2097152?(e[a++]=240+(r>>>18),e[a++]=128+(r>>>12&63),e[a++]=128+(r>>>6&63),e[a++]=128+(63&r)):r<67108864?(e[a++]=248+(r>>>24),e[a++]=128+(r>>>18&63),e[a++]=128+(r>>>12&63),e[a++]=128+(r>>>6&63),e[a++]=128+(63&r)):(e[a++]=252+r/1073741824,e[a++]=128+(r>>>24&63),e[a++]=128+(r>>>18&63),e[a++]=128+(r>>>12&63),e[a++]=128+(r>>>6&63),e[a++]=128+(63&r));return e}String.prototype.trim||function(){var t=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(t,"")}}();var TwgT={sendRequest:function(t){var e="",r=t.host,n=t.event;if(delete t.host,delete t.event,r&&n){r=r.replace(/\/+$/,""),e=n+"_"+twgb64ea(twgs2a(JSON.stringify(t)))+".png";var o=document.createElement("img");o.src=r+"/t/"+e,document.body.appendChild(o)}}};</script>
                    <script type="text/javascript">
            var oTwgTConfig = {
                   "host": "https://%host%",
                   "master_site_id": "%master_site_id%",
                   "event": "pp",
                   "ref_id": "%item_feed_reference_id%",
                   "variant_id": "%item_feed_variant_id%",
                   "currency": "%currency_iso_code%",
                   "country":"%country_iso_code%",
                   "price": "%price_including_taxes%"
               };
            TwgT.sendRequest(oTwgTConfig);
        </script>

Configuration for the Sales Confirmation page

Format and examples of values :
  • %host% (Character string): Value reported by your account manager. Ex: twenga.my-ecommerce-site.com
  • %master_site_id% (Integer): Value communicated by your account manager. Ex: 12548
  • %order_id% (Character String): Identifier of the order. Ex: 4587_HYTR
  • %currency_iso_code% (Character String): ISO 4217 currency code. Ex: EUR
  • %country_iso_code% (Character string) : ISO 3166-1 alpha-2. Optional value. Ex: FR. Please send empty string if the parameter is not available.
  • %attribution_weight% (Decimal): Weight of attribution attributed to Twenga. Decimal value between 0 and 1. 0 being the default value, and 1 to attribute the sale to Twenga. A "." must be used as a separator of the decimal part. Do not fill-in this value when attribution process is not real-time.
  • List of items in the basket. This list must contain as many values ​​as elements in the basket :
    • %item_feed_reference_id% (Character string): Product reference as it appears in the feed. Ex: 381223798UT207GR
    • %item_feed_variant_id% (Character string): Product variant identifier as it appears inthe feed. Optional value if it is not used in the feed. Ex: 123ABC. Leave carácter string empty if there is not variant for thisproduct or if the structure of your catalog doesn’t have variant at all.
    • %quantity% (Integer): Quantity ordered. Ex: 5
    • %price_excluding_taxes% (Decimal): Price excluding VAT and shipping fees. A "." must be used as a separator of the decimal part. Ex: 60.00
<script type="text/javascript">function twgb646(t){return t>64&&t<91?t-65:t>96&&t<123?t-71:t>47&&t<58?t+4:43===t?62:47===t?63:0}function twg6b64(t){return t<26?t+65:t<52?t+71:t<62?t-4:62===t?43:63===t?47:65}function twgb64ea(t){for(var e=2,r="",n=t.length,o=0,g=0;g<n;g++)e=g%3,g>0&&4*g/3%76==0&&(r+="\r\n"),o|=t[g]<<(16>>>e&24),2!==e&&t.length-g!=1||(r+=String.fromCharCode(twg6b64(o>>>18&63),twg6b64(o>>>12&63),twg6b64(o>>>6&63),twg6b64(63&o)),o=0);return r.substr(0,r.length-2+e)+(2===e?"":1===e?"=":"==")}function twgs2a(t){for(var e,r,n=t.length,o=0,g=0;g<n;g++)o+=(r=t.charCodeAt(g))<128?1:r<2048?2:r<65536?3:r<2097152?4:r<67108864?5:6;e=new Uint8Array(o);for(var a=0,i=0;a<o;i++)(r=t.charCodeAt(i))<128?e[a++]=r:r<2048?(e[a++]=192+(r>>>6),e[a++]=128+(63&r)):r<65536?(e[a++]=224+(r>>>12),e[a++]=128+(r>>>6&63),e[a++]=128+(63&r)):r<2097152?(e[a++]=240+(r>>>18),e[a++]=128+(r>>>12&63),e[a++]=128+(r>>>6&63),e[a++]=128+(63&r)):r<67108864?(e[a++]=248+(r>>>24),e[a++]=128+(r>>>18&63),e[a++]=128+(r>>>12&63),e[a++]=128+(r>>>6&63),e[a++]=128+(63&r)):(e[a++]=252+r/1073741824,e[a++]=128+(r>>>24&63),e[a++]=128+(r>>>18&63),e[a++]=128+(r>>>12&63),e[a++]=128+(r>>>6&63),e[a++]=128+(63&r));return e}String.prototype.trim||function(){var t=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(t,"")}}();var TwgT={sendRequest:function(t){var e="",r=t.host,n=t.event;if(delete t.host,delete t.event,r&&n){r=r.replace(/\/+$/,""),e=n+"_"+twgb64ea(twgs2a(JSON.stringify(t)))+".png";var o=document.createElement("img");o.src=r+"/t/"+e,document.body.appendChild(o)}}};</script>
                        <script type="text/javascript">
            var oTwgTConfig = {
                "host": "https://%host%",
                "master_site_id": "%master_site_id%",
                "event": "tx",
                "order_id": "%order_id%",
                "currency": "%currency_iso_code%",
                "country":"%country_iso_code%",
                "attribution_weight": "%attribution_weight%",
                "items": [
                    {"ref_id": "%item_feed_reference_id%", "variant_id": "%item_feed_variant_id%", "qty": "%quantity", "price_et": "%price_excluding_taxes%"},
                    {"ref_id": "%item_feed_reference_id%", "variant_id": "%item_feed_variant_id%", "qty": "%quantity", "price_et": "%price_excluding_taxes%"}
                    /* add a line for each item in the user's basket */
                ]
            };
            TwgT.sendRequest(oTwgTConfig);
        </script>