> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runconverge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Postscript

> An introduction to the Postscript Destination

export const OutboundLink = ({linkText, linkTarget}) => {
  return <a target="_blank" href={linkTarget}> {linkText} 
    <div className="inline h-3 w-3 fill-gray-500 dark:fill-gray-100 text-gray-500 dark:text-gray-300 ml-1 mr-1">
      <svg className="inline w-2.5 h-2.5 bg-gray-500 dark:bg-gray-300" style={{
    maskImage: `url('https://mintlify.b-cdn.net/v6.5.1/solid/up-right-from-square.svg')`,
    maskRepeat: "no-repeat",
    maskPosition: "center center"
  }}></svg> 
    </div>
    </a>;
};

export const IconText = ({name, text, iconSource = "mintlify", iconLocation = "before", iconType = "solid"}) => {
  const sourceUrl = iconSource === 'local' ? `url('/images/icons/${name}.svg')` : `url('https://mintlify.b-cdn.net/v6.5.1/${iconType}/${name}.svg')`;
  return <>
            <div className="inline-block pl-2">
                {iconLocation === 'before' && <div className="h-3.5 w-3.5 fill-gray-800 dark:fill-gray-100 text-gray-800 dark:text-gray-100 inline-block align-middle mr-2">
                        <svg className="w-4 h-4 bg-gray-800 dark:bg-gray-100 " style={{
    maskImage: sourceUrl,
    maskRepeat: "no-repeat",
    maskPosition: "center center"
  }} />
                    </div>}
                <span className="inline-block align-middle font-semibold fill-gray-800 dark:fill-gray-100 text-gray-800 dark:text-gray-100 pl-1 pr-2">{text}</span>
                {iconLocation === 'after' && <div className="h-3.5 w-3.5 fill-gray-800 dark:fill-gray-100 text-gray-800 dark:text-gray-100 inline-block align-middle mr-2">
                        <svg className="w-4 h-4 bg-gray-800 dark:bg-gray-100 pr-3" style={{
    maskImage: sourceUrl,
    maskRepeat: "no-repeat",
    maskPosition: "center center"
  }} />
                    </div>}
            </div>
        </>;
};

export const Icon = ({name}) => {
  return <div className="h-4 w-4 fill-gray-800 dark:fill-gray-100 text-gray-800 dark:text-gray-100 inline-block align-middle">
            <svg className="w-4 h-4 bg-gray-800 dark:bg-gray-100" style={{
    maskImage: `url('https://mintlify.b-cdn.net/v6.5.1/solid/${name}.svg')`,
    maskRepeat: "no-repeat",
    maskPosition: "center center"
  }} />
        </div>;
};

## Overview

Destination Type: <IconText text="Server-side" name="server" iconType="duotone" iconLocation="after" />

***

## Installation instructions

<Steps>
  <Step icon="key" title="1. Create a Postscript API key">
    1. In your Postscript dashboard, select your Shop Name and navigate to **API**.
    2. Click on **Create Security Key Pair** and confirm by selecting **Yes**.
    3. Click in **Add a label** and use a label that helps you identify the API key (e.g. `Converge`).
    4. Under **Private Key**, click on **Show** and to copy the Private Key.

    <Frame>
      <img src="https://mintcdn.com/converge/crQaBntMCFTIm3T-/images/destinations/postscript/postscript-1.png?fit=max&auto=format&n=crQaBntMCFTIm3T-&q=85&s=4a72ae3cd2639f01701760e24c57eeb4" alt="postscript-1" width="1258" height="429" data-path="images/destinations/postscript/postscript-1.png" />
    </Frame>
  </Step>

  <Step icon="list" title="2. Create the Converge Destination">
    5. In the Converge sidebar, click on <IconText name="arrow-right-from-line" text="Event streams" /> and then click **Create new Destination**.
    6. Select the **Postscript** destination and click **Next**.
    7. Give your destination a **name** (e.g. Postscript Destination) and click **Next**.
    8. Fill in the **Private API Key** you copied from **Postscript** and click **Next**.
    9. Select **Use default mapping** and click **Next**.

    <Note>You can find the Default mapping for the Postscript destination [here](#event-mapping). For more information on setting up Custom mappings, look [here](/destinations/event-mapping).</Note>

    10. Select the sources you want to forward events from, then click **Next**.

    <Note>This is a server-side destination, meaning that only server-side sources can be used with this destination. You can still select client-side sources but the events will not be sent to Postscript.</Note>

    11. Review any issues and click **Submit**.

    <Warning>If you are migrating from a previous Postscript to a Converge integration, make sure to **modify your Flows** to use the Converge Event Names and Event Properties [here](#event-mapping)</Warning>
  </Step>
</Steps>

***

## Converge functionality

This integration supports the following Converge destination functionality.

| Converge Feature                                     |       Supported       |
| ---------------------------------------------------- | :-------------------: |
| Custom Events                                        | <Icon name="check" /> |
| Filters                                              | <Icon name="xmark" /> |
| Server-side Conversions                              | <Icon name="check" /> |
| [Conversion amount](/destinations/conversion-amount) | <Icon name="check" /> |

***

## Adding product URL and image URL to Converge events to power Postscript flows

A common use case of the Postscript Destination is to build Postscript SMS Flows based on Converge Events.
As such, you might want to include a Product URL or Product Image URL in the Converge Event so you can leverage these in your flows.

To that end, you will want to extend the Converge event spec for the following events.
Once you add the custom properties to your events, Converge will automatically forward these to the Postscript Destination.

Find code examples below that illustrate where **you should add the Product URL and Product Image URL custom event properties**.

<AccordionGroup>
  <Accordion title="Viewed Product" icon="code">
    See the original `Viewed Product` spec [here](/sources/converge-spec.mdx#viewed-product)

    <CodeGroup>
      ```javascript JavaScript theme={null}
      cvg({
        method: "track",
        eventName: "Viewed Product",
        properties: {
          product_id: "123456",
          variant_id: "78910", 
          sku: "MY_SKU",
          name: "My Product",
          variant_name: "Vanilla", 
          price: 42,
          currency: "USD",
          vendor: "My Store",
          url: "https://mystore.com/this-product", // This is new
          image_url: "https://mystore.com/assets/product.png" // This is new
        },
      });
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Added To Cart" icon="code">
    See the original `Added To Cart` spec [here](/sources/converge-spec.mdx#added-to-cart)

    <CodeGroup>
      ```javascript JavaScript theme={null}
      cvg({
        method: "track",
        eventName: "Added To Cart",
        properties: {
          product_id: "123456",
          variant_id: "78910",
          sku: "MY_SKU",
          name: "My Product",
          variant_name: "Vanilla",
          price: 42,
          currency: "USD",
          quantity: 1,
          vendor: "My Store",
          url: "https://mystore.com/this-product", // This is new
          image_url: "https://mystore.com/assets/product.png" // This is new
        },
      });

      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Removed From Cart" icon="code">
    See the original `Removed From Cart` spec [here](/sources/converge-spec.mdx#removed-from-cart)

    <CodeGroup>
      ```javascript JavaScript theme={null}
      cvg({
        method: "track",
        eventName: "Removed From Cart",
        properties: {
          product_id: "123456",
          variant_id: "78910",
          sku: "MY_SKU",
          name: "My Product",
          variant_name: "Vanilla",
          price: 42,
          currency: "USD",
          quantity: 1,
          vendor: "My Store",
          url: "https://mystore.com/this-product", // This is new
          image_url: "https://mystore.com/assets/product.png" // This is new
        },
      });

      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

## Event mapping

Converge automatically maps the following events from the [Converge event spec](/sources/converge-spec) to the Postscript spec.

| Converge Event Name                                           | Postscript Event Name          |
| ------------------------------------------------------------- | ------------------------------ |
| [Viewed Product](/sources/converge-spec#viewed-product)       | `Converge - viewed_product`    |
| [Added To Cart](/sources/converge-spec#added-to-cart)         | `Converge - add_to_cart`       |
| [Started Checkout](/sources/converge-spec#started-checkout)   | `Converge - initiate_checkout` |
| [Viewed Collection](/sources/converge-spec#viewed-collection) | `Converge - viewed_collection` |
| [Placed Order](/sources/converge-spec#placed-order)           | `Converge - purchase`          |

You can find the property mapping for each event below:

<AccordionGroup>
  <Accordion title="Converge - viewed_product">
    | Postscript Property | Converge Property          |
    | ------------------- | -------------------------- |
    | `name`              | `name`                     |
    | `price_in_cents`    | `price` converted to cents |
    | `resource_id`       | `product_id`               |
    | `resource_type`     | Fixed to `"product"`       |
    | `sku`               | `sku`                      |
    | `variant_name`      | `variant_name`             |
    | `variant_id`        | `variant_id`               |
    | `vendor`            | `vendor`                   |
    | `currency`          | `currency`                 |
    | `url`               | `url`                      |
    | `image_url`         | `image_url`                |
  </Accordion>

  <Accordion title="Converge - add_to_cart">
    | Postscript Property | Converge Property    |
    | ------------------- | -------------------- |
    | `name`              | `name`               |
    | `price_in_cents`    | `price`              |
    | `resource_id`       | `product_id`         |
    | `resource_type`     | Fixed to `"product"` |
    | `sku`               | `sku`                |
    | `variant_name`      | `variant_name`       |
    | `variant_id`        | `variant_id`         |
    | `vendor`            | `vendor`             |
    | `currency`          | `currency`           |
    | `url`               | `url`                |
    | `image_url`         | `image_url`          |
    | `quantity`          | `quantity`           |
  </Accordion>

  <Accordion title="Converge - initiate_checkout">
    | Postscript Property       | Converge Property                                        |
    | ------------------------- | -------------------------------------------------------- |
    | `item_names`              | `name` for each item                                     |
    | `item_vendors`            | `vendor` for each item                                   |
    | `coupon`                  | `coupon` (separated by `,`)                              |
    | `total_value_in_cents`    | `total_price` converted to cents                         |
    | `discount_value_in_cents` | `total_discount` converted to cents                      |
    | `tax_value_in_cents`      | `total_tax` converted to cents                           |
    | `shipping_value_in_cents` | `total_shipping` converted to cents                      |
    | `currency`                | `currency`                                               |
    | `items`                   | list of items (same mapping as `Converge - add_to_cart`) |
  </Accordion>

  <Accordion title="Converge - viewed_collection">
    | Postscript Property | Converge Property |
    | ------------------- | ----------------- |
    | `category`          | `name`            |
    | `category_id`       | `id`              |
    | `image_url`         | `image_url`       |
    | `quantity`          | `quantity`        |
  </Accordion>

  <Accordion title="Converge - purchase">
    | Postscript Property       | Converge Property                                        |
    | ------------------------- | -------------------------------------------------------- |
    | `order_id`                | `event_id`                                               |
    | `item_names`              | `name` for each item                                     |
    | `item_vendors`            | `vendor` for each item                                   |
    | `coupon`                  | `coupon` (separated by `,`)                              |
    | `total_value_in_cents`    | `total_price` converted to cents                         |
    | `discount_value_in_cents` | `total_discount` converted to cents                      |
    | `tax_value_in_cents`      | `total_tax` converted to cents                           |
    | `shipping_value_in_cents` | `total_shipping` converted to cents                      |
    | `currency`                | `currency`                                               |
    | `items`                   | list of items (same mapping as `Converge - add_to_cart`) |
  </Accordion>
</AccordionGroup>
