---
title: Set up Universal Integration (client-side) with a script
description: Follow the steps below to integrate ProfitMetrics Universal Client-Side Integration through Direct script integration
---

[Skip to content](https://knowledge.profitmetrics.io/how-to-set-up-universal-client-side-integration-through-direct-script-integration#main-content)

[![ProfitMetrics logo black version](https://knowledge.profitmetrics.io/hs-fs/hubfs/pm_logotype_blue.png?width=193&height=28&name=pm_logotype_blue.png)](https://knowledge.profitmetrics.io/?hsLang=en)

Open main navigation

Close main navigation

- [Contact Support](https://knowledge.profitmetrics.io/kb-ticket/new)

[Contact Support](https://knowledge.profitmetrics.io/kb-ticket/new?hsLang=en)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [Knowledge base](https://knowledge.profitmetrics.io/?hsLang=en)
2. [E-commerce Platforms](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en)
3. [Universal Integration (Clientside)](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#universal-integration-clientside)

# Set up Universal Integration (client-side) with a script

## Follow the steps below to integrate ProfitMetrics Universal Integration via direct script.

**There are two scripts to integrate:**

1. “pmOriginTrack.js” - this should be placed unmodified on all pages on the webshop
2. “pmLogOrder.js” - this should be put on the order confirmation page. This requires adaptation

### **Integrating pmOriginTrack.js**

This file should be loaded on all pages. This script captures the source of the visitor, along with the google analytics client id(if applicable). There are no configuration or modifications required for this script.

[Download pmOriginTrack.js here](https://my.profitmetrics.io/customer/integrations_universalwebshop.php?download=pmOriginTrack.js)

### **Integrating pmLogOrder.js**

This script should be loaded on the order confirmation page shown to the customer after successful payment. This script contains a javascript function called “pmLogOrder(pid, orderspec)” that sends the order data + tracking data to profitmetrics.

This function takes two parameters, the profitmetrics website id, and the orderspec itself. The function then reads out the tracking data obtained by pmOriginTrack.js and sends it along automatically.

The profitmetrics website id, in the script referred to as “pmId” is specific to the website inside the profitmetrics account, so it is important to use the correct id for the website in case of multiple websites, as this has already been prefilled to the currently active website in the profitmetrics webinterface at time of download.

[Download pmLogOrder.js here](https://my.profitmetrics.io/customer/integrations_universalwebshop.php?download=pmLogOrder.js)

### **Orderspec specification**

The orderspec is a json/JavaScript structure, and it looks something like this:

`var orderspec = {`  
`id, // string`  
`orderEmail, // string`  
`shippingMethod, // string, optional`  
`priceShippingExVat, // number, optional`  
`priceTotalExVat, // number`  
`paymentMethod, // string, optional`  
`currency, // string`  
`products: [{`  
`sku, // string`  
`qty, // number`  
`priceExVat // number`  
`}]`  
`}`

 

Please note the data types to avoid problems. It is acceptable to provide a number to a field that specifies a string, but NOT the opposite.

**A few things to note:**

1. The id field is the order id, and must be unique
2. The product sku must be that of the fully qualified variant purchased, and identical to the sku/product id in the feed of products loaded into profitmetrics. It must not be an empty string.
3. The currency must be in 3 letter ISO 4217 format, Examples: “DKK”, “EUR”, “USD”
4. While some fields are optional, we strongly recommend filling out if at all possible, as these are required for certain features beyond the core profit calculations

### **Example orderspec’s**

**Example 1: Hardcoded**

`var orderspec = { id: "123", orderEmail: "testbuyer@webshop.com", shippingMethod: "UPS", priceShippingExVat: 79, priceTotalExVat: 716, paymentMethod: "Paypal", currency: "DKK", products: [{ sku: "tshirt11", qty: 2, priceExVat: 129 },{ sku: "jeans6423", qty: 1, priceExVat: 379 }] }`

**Example 2: Realworld From datalayer+DOM, via google tagmanager**

`// read out datalayer transaction products, deserializing if required`  
`var transactionProducts = dataLayer[0].transactionProducts;`  
`if( typeof dataLayer[0].transactionProducts === 'string' ) {`  
`transactionProducts = JSON.parse( dataLayer[0].transactionProducts );`  
`}`

`// build up product array, taking care with price datatype`  
`var pmProducts = [];`  
`for( i = 0; i < transactionProducts.length; i++ ) {`  
`pmProducts.push({`  
`sku: transactionProducts[i].content_id,`  
`qty: transactionProducts[i].quantity,`  
`priceExVat: transactionProducts[i].priceexcludingtax.replace(",", "")`  
`});`  
`}`

`// obtain these from the DOM as datalayer did not contain`  
`var orderEmail = document.getElementById("pmExtraData").getAttribute("data-orderemail");`  
`var shippingMethod = document.getElementById("pmExtraData").getAttribute("data-shippingmethod");`

`// build orderspec with data`  
`var orderspec = {`  
`id: dataLayer[0].transactionId,`  
`currency: 'DKK',`  
`shippingMethod: shippingMethod,`  
`orderEmail: orderEmail,`  
`products: pmProducts,`  
`priceShippingExVat: dataLayer[0].transactionShipping,`  
`priceTotalExVat: dataLayer[0].transactionTotal - dataLayer[0].transactionTax`  
`};`

 

**Note about embedding the scripts**  
It is fully supported to embed the scripts on the page either via for example google tagmanager, referencing the script to load as an external file, or embedding directly onto the pages. We very strongly recommend to embed directly on your order confirmation page, or via google tagmanager.

**Note about transferring data via template+DOM**  
On some ecommerce platforms it may seem easiest to transfer the data required into the DOM via hidden div or similar. While this does indeed work, care needs to be taken in case data is put in the innerHTML of DOM elements, as apple browsers attempt to transform numbers of a certain length into tel: links, and in our experience SKUs on products can often be numerical and of same length as telephone numbers.

- [Getting Started](https://knowledge.profitmetrics.io/getting-started?hsLang=en#main-content)

    - [Learn the Basics](https://knowledge.profitmetrics.io/getting-started?hsLang=en#learn-the-basics)
    - [Prepare for Onboarding](https://knowledge.profitmetrics.io/getting-started?hsLang=en#prepare-for-onboarding)
    - [Account Setup](https://knowledge.profitmetrics.io/getting-started?hsLang=en#account-setup)
- [E-commerce Platforms](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#main-content)

    - [Shopify](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#shopify)
    - [WooCommerce](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#woocommerce)
    - [Magento](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#magento)
    - [PrestaShop](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#prestashop)
    - [BigCommerce](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#bigcommerce)
    - [Shopware](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#shopware)
    - [DanDomain & Related](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#dandomain-related)
    - [Universal Integration (Clientside)](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#universal-integration-clientside)
    - [Universal Integration (Server-side Hybrid)](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#universal-integration-server-side-hybrid)
    - [Other Platforms](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#other-platforms)
    - [Developer Documentation](https://knowledge.profitmetrics.io/e-commerce-platforms?hsLang=en#developer-documentation)
- [Ad Channels](https://knowledge.profitmetrics.io/ad-channels?hsLang=en#main-content)

    - [Google Ads](https://knowledge.profitmetrics.io/ad-channels?hsLang=en#google-ads)
    - [Meta (Facebook/Instagram)](https://knowledge.profitmetrics.io/ad-channels?hsLang=en#meta-facebook-instagram)
    - [Microsoft Bing Ads](https://knowledge.profitmetrics.io/ad-channels?hsLang=en#microsoft-bing-ads)
    - [Google Analytics 4](https://knowledge.profitmetrics.io/ad-channels?hsLang=en#google-analytics-4)
    - [Partner-ads](https://knowledge.profitmetrics.io/ad-channels?hsLang=en#partner-ads)
    - [Other Channel Configuration](https://knowledge.profitmetrics.io/ad-channels?hsLang=en#other-channel-configuration)
- [Tracking & Conversion Setup](https://knowledge.profitmetrics.io/tracking-conversion-setup?hsLang=en#main-content)

    - [Overview](https://knowledge.profitmetrics.io/tracking-conversion-setup?hsLang=en#overview)
    - [Conversion Booster for Google Ads](https://knowledge.profitmetrics.io/tracking-conversion-setup?hsLang=en#conversion-booster-for-google-ads)
    - [Conversion Booster for Meta](https://knowledge.profitmetrics.io/tracking-conversion-setup?hsLang=en#conversion-booster-for-meta)
    - [Conversion Booster Custom Pixels](https://knowledge.profitmetrics.io/tracking-conversion-setup?hsLang=en#conversion-booster-custom-pixels)
    - [Enhanced Conversions](https://knowledge.profitmetrics.io/tracking-conversion-setup?hsLang=en#enhanced-conversions)
- [Shopping Booster](https://knowledge.profitmetrics.io/shopping-booster?hsLang=en#main-content)

    - [Overview & Setup](https://knowledge.profitmetrics.io/shopping-booster?hsLang=en#overview-setup)
    - [Supplemental Feeds](https://knowledge.profitmetrics.io/shopping-booster?hsLang=en#supplemental-feeds)
    - [Campaigns & Labels](https://knowledge.profitmetrics.io/shopping-booster?hsLang=en#campaigns-labels)
    - [Troubleshooting](https://knowledge.profitmetrics.io/shopping-booster?hsLang=en#troubleshooting)
- [Product Feed & Costs](https://knowledge.profitmetrics.io/product-feed-costs?hsLang=en#main-content)

    - [Product Feed](https://knowledge.profitmetrics.io/product-feed-costs?hsLang=en#product-feed)
    - [Shipping & Payment Costs](https://knowledge.profitmetrics.io/product-feed-costs?hsLang=en#shipping-payment-costs)
    - [Expenses](https://knowledge.profitmetrics.io/product-feed-costs?hsLang=en#expenses)
- [Dashboard, Orders & Reporting](https://knowledge.profitmetrics.io/dashboard-orders-reporting?hsLang=en#main-content)

    - [Dashboard & Orders](https://knowledge.profitmetrics.io/dashboard-orders-reporting?hsLang=en#dashboard-orders)
    - [Looker Studio](https://knowledge.profitmetrics.io/dashboard-orders-reporting?hsLang=en#looker-studio)
    - [Google BigQuery](https://knowledge.profitmetrics.io/dashboard-orders-reporting?hsLang=en#google-bigquery)
- [Account & Billing](https://knowledge.profitmetrics.io/account-billing?hsLang=en#main-content)

    - [Users & Access](https://knowledge.profitmetrics.io/account-billing?hsLang=en#users-access)
    - [Billing & Invoices](https://knowledge.profitmetrics.io/account-billing?hsLang=en#billing-invoices)
- [Privacy & Consent](https://knowledge.profitmetrics.io/privacy-consent?hsLang=en#main-content)

    - [GDPR](https://knowledge.profitmetrics.io/privacy-consent?hsLang=en#gdpr)
    - [Consent Management Platforms](https://knowledge.profitmetrics.io/privacy-consent?hsLang=en#consent-management-platforms)
    - [Google Consent Mode](https://knowledge.profitmetrics.io/privacy-consent?hsLang=en#google-consent-mode)
- [For Agencies](https://knowledge.profitmetrics.io/for-agencies?hsLang=en#main-content)

    - [Getting Started as an Agency](https://knowledge.profitmetrics.io/for-agencies?hsLang=en#getting-started-as-an-agency)
    - [Agency Certification](https://knowledge.profitmetrics.io/for-agencies?hsLang=en#agency-certification)
- [Shopify](https://knowledge.profitmetrics.io/shopify?hsLang=en)
- [PrestaShop](https://knowledge.profitmetrics.io/prestashop?hsLang=en)
- [Google Ads](https://knowledge.profitmetrics.io/google-ads?hsLang=en#main-content)

    - [troubleshoot](https://knowledge.profitmetrics.io/google-ads?hsLang=en#troubleshoot)
- [Meta (Facebook / Instagram)](https://knowledge.profitmetrics.io/meta-facebook-instagram?hsLang=en)
- [Uncategorized](https://knowledge.profitmetrics.io/uncategorized?hsLang=en)
- [Billing](https://knowledge.profitmetrics.io/billing?hsLang=en)
- [Google Sheets](https://knowledge.profitmetrics.io/google-sheets?hsLang=en)
- [Account](https://knowledge.profitmetrics.io/account?hsLang=en)
- [Ideal Shop](https://knowledge.profitmetrics.io/ideal-shop?hsLang=en)

[![ProfitMetrics logo black version](https://knowledge.profitmetrics.io/hs-fs/hubfs/pm_logotype_blue.png?width=193&height=28&name=pm_logotype_blue.png "ProfitMetrics logo black version")](https://profitmetrics.io)

<https://www.facebook.com/ProfitMetrics/> <https://podcasts.apple.com/> [mailto:support@profitmetrics.io](mailto:support@profitmetrics.io)

Copyright © 2026, ProfitMetrics ApS