# WooCommerce

In order to integrate with WooCommerce one needs to place Offer18 Image Pixel in WooCommerce (WordPress). <br>

### [<mark style="color:blue;">Get Image Pixel</mark>](https://knowledgebase.offer18.com/network/postback-integration)

***

## WooCommerce Integration

There are two ways to add Offer18 Image Pixel to WooCommerce:-<br>

### Option 1 : WordPress Plugin

One can use WordPress plugin "WooCommerce Conversion Tracking" by weDevs.

Steps to follow:

1. Login to the WordPress Admin dashboard.
2. Go to "Plugins" and search "WooCommerce Conversion Tracking".\ <br>

   <div align="left"><figure><img src="https://295230641-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F41f2EboJipeUA6flsLGK%2Fuploads%2FIwPH7OQzuJIym04NSF2d%2Fimage.png?alt=media&#x26;token=4f7ad8a2-8857-4200-adf6-79f0c8e6e929" alt=""><figcaption><p><br></p></figcaption></figure></div>
3. Install and activate "WooCommerce Conversion Tracking" by weDevs.
4. Go to Conversion Tracking (sub-menu to the WooCommerce tab).
5. Enable "Custom" and Place Offer18 Pixel in "Successful Order."&#x20;

<figure><img src="https://295230641-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F41f2EboJipeUA6flsLGK%2Fuploads%2Ftd6gcW4r0qLVhTUyxWe0%2Fimage.png?alt=media&#x26;token=fa725e3b-8862-47fe-b171-1f428a90e577" alt=""><figcaption></figcaption></figure>

6. Go to Save Changes

One can receive dynamic values using tokens provided by the Plugin.\
For Example:  **\&sale** (Offer18) can be added to an Image pixel containing **{order\_subtotal}**

**Example Image pixel with sale parameter**

```
<img src="https://example.o18.click/p?mid=000&t=i&gb=1&sale={order_subtotal}" width="0" height="0"> 
```

***

Video Tutorial - WooCommerce Integration

{% embed url="<https://youtu.be/cayaPMkNzBk>" %}

***

### Option 2 : Custom Configuration

One can configure the **Conversion Tracking Syntax** in a custom configuration of the WordPress. Offer18's Conversion Tracking Syntax is given below.

#### **Conversion Tracking Syntax**

```php
add_action('woocommerce_thankyou', 'custom_track_o18');

function custom_track_o18($order_id)
{
  $order_data = wc_get_order($order_id);
  $total_amount = $order_data->get_subtotal();
  $currency = $order_data->get_currency();
  $order_number = str_replace('#', '', $order_data->get_order_number());
  echo '<img src="https://[domain]/p?m=[account_id]&t=i&gb=1&sale=' . $total_amount . '&adv_sub1=' . $order_number . '&currency='. $currency.'" width="0px" height="0px">';
}
```

{% hint style="info" %}
**Required Changes**\
\
Replace \[domain] with the tracking domain and \[account\_id] with the user account id in the script

For Example

\[domain] = **example.o18.click**\
\[account\_id]  = **0000**
{% endhint %}

Steps to follow

1. Login to the WordPress Admin dashboard.
2. Go to Appearance **»** Theme File Editor.
3. Open the **functions.php** file.
4. Place Offer18's Conversion Tracking Syntax in this file.

<figure><img src="https://295230641-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F41f2EboJipeUA6flsLGK%2Fuploads%2FMu5knLvdnD4sHqd6Hxi3%2Fimage.png?alt=media&#x26;token=e612c9d6-8aa9-4f79-a279-25f4a58ff278" alt=""><figcaption></figcaption></figure>

5. Go to "Update File."
