SamCart

Configure the OptiPub SamCart Integration

📘

OptiPub Integrations

Integrations can be found in OptiPub > Administration > System Settings > Integrations


OptiPub SamCart Integration

Activate the SamCart Integration in OptiPub

To activate OptiPub's SamCart Integration you will need a SamCart API Key and Subdomain.

Gather Information from SamCart

API Key

Email [email protected] to request an API Key for your account. Review the SamCart API SamCart documentation for more information.

Subdomain

Login to your SamCart Account, and open Apps in the menu. Copy your subdomain from the URL (https://app.samcart.com/marketplace/{YOUR_SUBDOMAIN}/apps).

Example URL: https://app.samcart.com/marketplace/optipub/apps

Example Subomain: optipub


Configure OptiPub SamCart Integration

  1. Navigate to OptiPub > Administration > Integrations > SamCart and click Add +.
  2. Fill in your API Key and Subdomain.
  3. Toggle Enable SamCart on.
  4. Copy the Webhook URL that appears.
  5. Click Save.

Configure SamCart

Configure the Webhooks App

Review the Using Webhooks on SamCart SamCart documentation for more information.

Connect the OptiPub Webhook URL to SamCart

  1. Login to your SamCart Account, and open Apps in the menu.
  2. Explore Other apps, and click Install in the Webhooks card.
  3. Paste the OptiPub Webhook URL into the Notify Url text input.
  4. Click Connect.

If Webhooks are already installed, click Open App on the Webhooks card, then click the 3-dot Options menu in the top right and click Connect New App Instance.

Confirm Connection

Scroll down to the Logs section of the Webhooks App, and select Configuration logs.

An Integration successfully connected/refreshed. log should exist for the Connect App action. If no log is present, click Refresh Logs.

Add Global Rules to Webhook App

Add these Global Rules to the Webhooks App. Repeat for each trigger listed in the Triggers table below.

  1. Select Global in the Rules section.
  2. Click + Add New Rule
    1. Select the Global Rule rule type.
    2. Select the Send Notify Url POST action.
    3. Select a Trigger from the table below.
    4. Click Add Rule.
Triggers
Product Purchased
Product Refunded
Product Partially Refunded
Subscription Canceled
Subscription Started
Subscription Restarted

Configure SamCart Settings

Open SamCart Settings from the bottom of the main menu.

Add Custom Fields

Review the Custom Fields SamCart documentation for more information.

Open Custom Fields from the Settings menu.

Create a custom field named optipub_effort_id.

  1. Click New Custom Field
    1. Set Internal Field Name to optipub_effort_id.
    2. Set Checkout Page Label to OptiPub Effort ID.
    3. Set Field Type to Hidden Value.
    4. Click Save.

After saving, SamCart will automatically set a Slug name for the field.


Add OptiPub Tracking to SamCart Checkout Pages

Review the Pixels and Custom Conversion Tracking SamCart documentation for more information.

Open Tracking & Pixels from the Settings menu.

Paste the following into the Embed HTML/Scripts in Header then Save Changes.

<script src="https://assets.optipub.com/frontend/js/samcart-tracking.js"></script>

Maintaining the OptiPub SamCart Integration

Procedures in this section are required for all existing products, and new products added to SamCart.

Update SamCart Product Settings

Add the optipub_effort_id custom field to SamCart Products

Return to the main menu and open Products.

  1. Click the Name of a product.
    1. Open the Details view and scroll down to the Checkout Controls section.
    2. Click inside Custom Fields so that a dropdown appears and select the optipub_effort_id custom field.
    3. Click Save Changes.
    4. Click Back to Product List.

Repeat for each product that will have an Order Page created in OptiPub Landing Pages.


Map SamCart Products to OptiPub Publications

📘

All Products Require Publication Mapping

All Published SamCart Products must be mapped to a corresponding OptiPub Publication.

This mapping is required for OptiPub to accurately process subscription and product webhook events received from SamCart.

OptiPub syncs all Published, Test Mode, and Archived products.

  1. Navigate to OptiPub > Administration > Publications.
    1. Edit the Publication using the 3-dot action menu in the table.
    2. Continue to the Additional Information step.
    3. Click on SamCart Products in the SamCart Mapping section to display the products dropdown list.
    4. Select each SamCart Product belonging to the OptiPub Publication.
    5. Click Save.

Finding SamCart Products:

OptiPub

  • OptiPub displays the SamCart Product ID and Name.
  • The dropdown list is sorted by product ID.
  • Type a name or ID in the product area to filter the available products in the dropdown.

SamCart

  • Product search will work using the product ID displayed in OptiPub.
  • Use a consistent naming scheme to organize products.
  • Optional: Filter Products using Tags to review.

Using the SamCart Integration

Embedding a SamCart Order Form in OptiPub Landing Pages

You can create and host order pages in OptiPub to process SamCart product orders. OptiPub is able to connect web ads, email text ads, and promos to order pages and track granular statistics for each effort using Campaigns.

OptiPub provides a SamCart Order Form component to easily embed order forms for SamCart products in OptiPub Landing Pages.

OptiPub Landing Page link URLs do not need the optipub_effort_id parameter. Order pages created in OptiPub will automatically insert the effort id into the embedded SamCart order form.


Integrating SamCart Orders with OptiPub Campaigns

📘

OptiPub Effort IDs are created in OptiPub Campaigns. Create a Campaign and then Generate a Campaign Link to create an effort id to use for the optipub_effort_id custom field value.

As always, make sure your SamCart Product has the optipub_effort_id custom field configured and the product is mapped to a publication .


Include the custom field optipub_effort_id=<effort_id> as a URL parameter in links to your SamCart order page for the SamCart order event to map the OptiPub subscription to a Campaign.

Example Samcart Link: https://secure.optipub.com/products/my-product-name?optipub_effort_id=123

If you use tracking links to redirect to your order page, make sure to include optipub_effort_id=<effort_id> in your tracking links, and that the tracking links pass the parameter to your SamCart order page.


Generating Campaign Links for SamCart Order Pages

Campaign links to External URLs for External Offers must include the optipub_effort_id=<effort_id> parameter to map the order and subscription back to an OptiPub campaign.

Campaign links to order pages hosted on OptiPub landing pages do not need the parameter. But if you are hosting promotional landing pages on OptiPub that link to an external order page, the links to the order page must have the parameter.

This requirement is only necessary to have OptiPub subscriptions mapped to a campaign. If an optipub_effort_id is not passed in your SamCart order form, the subscription will be created successfully, but with an N/A campaign.


Create SamCart Variables in OptiPub

When a SamCart product purchase triggers a webhook, it sends customer fields from the order form to OptiPub. To store the customer data in OptiPub, create variable names that match the webhook’s customer fields.

Create these OptiPub Variables to store SamCart order form data to the OptiPub Subscriber:

OptiPub Variables
name
first_name
last_name
phone_number
customer_id
SamCart Custom FIeld Names

Review SamCart Event Hook Logs

Navigate to OptiPub > Administration > System Settings > Integrations > SamCart [Logs]

OptiPub logs every webhook received from SamCart and timestamps created date and the latest failed processing attempt and retry attempt.

These logs are accessible from the OptiPub Integrations page. Logs can be filtered by event data, or by the date the log was Created, Failed, and Retried.

OptiPub will send a status response back to SamCart for each webhook, and SamCart will reattempt delivery once per day for up to 3 days if it does not receive a success status response.

❗️

If OptiPub fails to process an event, most likely the SamCart Product is not mapped to an OptiPub Publication.

After you create the mapping, you can retry the event.


Retrying a webhook event in OptiPub

You can retry any event by clicking Retry from the actions menu for the event log and OptiPub will attempt to process the event again to create or update the OptiPub subscription effected by the event.

T


SamCart Webhook Logs

SamCart Webhook Logs

Search the Data field by email, product ID, or any other value sent in the webhooks. The Failed, Retried, and Created date values can be filtered by date range.

Retry Orders for Products not mapped to a Publication

If SamCart product orders are received before the product is mapped to an OptiPub publication, you can review logs from the integration page at OptiPub > Administration > System Settings > Integrations by clicking on the Logs link in the SamCart card.

before orders are received, you can , you can search for the product ID, and retry the Order events to create the OptiPub Subscriptions like normal.