Preferences - Python - Mercado Pago Developers
Which documentation are you looking for?

Do not know how to start integrating? 

Check the first steps

Create preference

It is possible to create Preferences using the SDK below. For details on request parameters, check the Create preference API.

          
# Mercado Pago SDK
import mercadopago
# Add Your credentials
sdk = mercadopago.SDK("PROD_ACCESS_TOKEN")
# Create a preference object
preference_data = {
    "items": [
        {
            "title": "My Item",
            "quantity": 1,
            "unit_price": 75
            
        }
    ]
}
preference_response = sdk.preference().create(preference_data)
preference = preference_response["response"]

        

Associate Facebook Ads

You can associate the preference with a pixel to track the conversions of Facebook ads. To obtain details about the request parameters, consult the API Create Preference.

Add the following code in the preference and replace the pixel_id value with its identifier.

          
# Associate your Facebook Pixel
preference_data = {
    # ...
    "tracks": [
        {
            "type": "facebook_ad",
            "values": {
                "pixel_id": "PIXEL_ID"
            }
        }
    ]
}
preference_response = sdk.preference().create(preference_data)
preference = preference_response["response"]

        

Associate Google Ads

You can associate a tag with your preference for tracking Google Ads conversions. For details on request parameters, check the API Create Preference.

Add the code in the preference and replace the CONVERSION_ID and CONVERSION_LABEL values with the data from your tag.

          
# Associate your tag
preference_data = {
    # ...
    "tracks": [
        {
            "type": "google_ad",
            "values": {
                "conversion_id": "CONVERSION_ID",
                "conversion_label": "CONVERSION_LABEL"
            }
        }
    ]
}
preference_response = sdk.preference().create(preference_data)
preference = preference_response["response"]