When customers make a purchase from your shop on Facebook or Instagram, the checkout process takes place on your own website. You'll need to build a checkout URL that will allow customers to complete their shops purchases seamlessly on your website.
Checkout URL receives products from cart.
You will need to provide a checkout URL that can receive cart information:
Once you build your checkout URL, you can test your checkout by adding products and promo codes. Make sure the products you’ve selected appear in your website’s checkout with the right quantity and price, and that your subtotal is accurate. If you’ve added a promo code, make sure it’s been applied. Meta will also automatically review your website’s checkout experience on a periodic basis to ensure it’s working properly.
An endpoint will need to exist on your website that Meta can use to direct users to check out on your website. This may be an existing page or a dedicated one you create for this experience.
Example of an endpoint: https://www.example.com/checkout
You will receive a comma-separated list of products in the products query string parameter. For each product, the ID and quantity are separated by a colon. Commas (%2C) and colons (%3A) are escaped according to RFC 3986.
Example of how your URL handles products: https://www.example.com/checkout?products=12345%3A3%2C23456%3A1
Parameter: products=12345%3A3%2C23456%3A1
Decoded: products=12345:3,23456:1
| Product ID in Your Meta Catalog | Quantity |
|---|---|
12345 | 3 |
23456 | 1 |
You will optionally receive a coupon to be applied in the coupon query string parameter. This coupon code should be validated and applied to the cart.
Example of how your URL handles coupons: https://www.example.com/checkout?products=12345%3A3%2C23456%3A1&coupon=SUMMERSALE20
Parameter: coupon=SUMMERSALE20
After validating the products, quantities and optional coupon, you can now display the checkout experience to the user.
Additional parameters are provided for tracking conversions (see full reference here). If you perform a redirect to a different URL, be sure to pass along these parameters to that URL.
The provided sample code is representative of handling needed to support a compatible checkout URL. You will need to adapt handling to meet your specific needs. Thoroughly test with your catalog to ensure customers have a smooth experience.
# views.py
from django.http import JsonResponse
from django.views import View
class CheckoutView(View):
def get(self, request):
products_param = request.GET.get('products', '')
coupon = request.GET.get('coupon', None)
# Parse products
product_quantities = {}
if products_param:
for entry in products_param.split(','):
try:
product_id, quantity = entry.split(':')
product_quantities[product_id] = int(quantity)
except ValueError:
continue # Skip malformed entries
# Build response
response_data = {
'products': product_quantities,
'coupon': coupon if coupon else 'No coupon applied'
}
return JsonResponse(response_data)
# urls.py
from django.urls import path
from .views import CheckoutView
urlpatterns = [
path('checkout/', CheckoutView.as_view(), name='checkout'),
]You will be required to use our checkout validation tool in Commerce Manager to submit your checkout URL for your shop. You will see this tool during onboarding when you first create your shop, or you can find it in your Commerce Manager settings after you have created your shop. We recommend to test following these 3 steps:
If you store cart information in cookies or local storage, make sure that the cart is cleared on each call to the endpoint so that new items can be added each time. This ensures that your buyers don’t see products previously in their cart. You may add an additional parameter onto the endpoint to do this (for example: https://www.example.com/checkout?clear=true).
The products specified in the products parameter should be added to the cart with the given quantities. Please make sure that the product IDs used in your code are the same product IDs from the catalog. If the products are no longer available or out of stock, inform the user.
If a coupon code is provided, it should also be applied to the cart. If the coupon code is invalid or expired, inform the user.
After all the required items are added to the cart, display your checkout page. To ensure a frictionless user journey, please confirm that your checkout page:
Test your endpoint with various product and promotional code combinations. Also consider edge cases listed below and handle them appropriately:
UTM parameters will be passed in the URL, so be sure to incorporate any tracking mechanisms that you have on the checkout page to be handled for this use case.
If users navigate from the shop to your website (without directly going to your website checkout), we automatically append the following static UTM parameters to the URLs:
utm_source=IGShoppingutm_medium=SocialThese parameters are appended for traffic coming from a shop on Instagram or Facebook. They are also added to any parameters you have already set at the product level in your catalog or data feed (for example, utm_content).
If you link directly to your website checkout, and users proceed from your shop’s cart to your website, we automatically append the parameter:
cart_origin with a value of either 'facebook', 'instagram', or 'meta_shops' depending on the source of the checkout. cart_origin is appended in addition to:
Any parameters you have set in your Checkout URL (for organic traffic); and
Any UTM parameters you have set at the campaign level (for paid traffic).
| Query Parameter | Description | Examples |
|---|---|---|
| A comma-separated list of products. For each product, the ID and quantity are separated by a colon. Commas (%2C) and colons (%3A) are escaped according to RFC 3986. Your web server should provide an API similar to decodeURIComponent to parse these parameters. Products with comma (,) or colon (:) characters in their ID are not supported. |
** This example cart has the following two products:
|
| A single, optional coupon code to apply at checkout. This may include an email opt-in promo code. |
|
| A Facebook Click ID - automatically added to all outbound links from Facebook and Instagram. |
|
| The source app the buyer is using to checkout. Possible values include “facebook”, “instagram”, and “meta_shops”. These are for Facebook, Instagram and Commerce Manager respectively. |
|
| Identifies the traffic source. Included if the originating ad included this parameter. |
|
| Specifies the marketing channel or medium. Included if the originating ad included this parameter. |
|
| Identifies ad creative variations or placements. Included if the originating ad included this parameter. |
|
| Identifies ad creative variations or placements. Included if the originating ad included this parameter. |
|