If you’re looking at building affiliate stores and are automating some of your processes like creating tracking links from the impact.com affiliate platform, then this article may help you.

Impact.com is one of the most popular affiliate network platforms where advertisers can promote their products and services and for publishers to find programs to promote.

I’ve been using impact.com for a few years promoting different companies and it has been a great experience. Never had any problems and their support is great. I normally receive a response to my question overnight with helpful information.

Receiving payments is also easy and there are no fees involved if paying directly into a bank account.

I recently wanted to automatically generate the affiliate tracking link using a PHP function and I managed to do that by using some help from ChatGPT. I decided to share this code with you if it helps someone else. Here’s the code:

function createTrackingLink($deepLink) {

$accountSid = 'xx';
$authToken = 'yy';
$programId = '1111';
$type = 'vanity';


    // Set the API endpoint for creating a tracking link
    $apiEndpoint = "https://api.impact.com/Mediapartners/$accountSid/Programs/$programId/TrackingLinks";

    // Prepare data for the request
    $data = [
        'DeepLink' => $deepLink,
        'Type' => $type
    ];

    // Set up cURL
    $ch = curl_init($apiEndpoint);

    // Set cURL options
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_USERPWD, "$accountSid:$authToken");
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Accept: application/json',
    ]);

    // Execute the cURL request
    $response = curl_exec($ch);
    //echo "response". $response;
    // Close cURL
    curl_close($ch);

    // Decode the JSON response
    $responseData = json_decode($response, true);
    //echo "response data". $responseData;
    // Extract the tracking link from the response
    $trackingLink = $responseData['TrackingURL'];
    //echo "tracking link is:". $trackingLink;
    return "https://".$trackingLink;
}

Let me explain some of the variables and how to obtain them on impact.com I will use Shopify as the brand for this example.

$deeplink – this is the product link from the affiliate advertisers’ website. It is generally the link you would manually enter on the Landing Page

The Simple Entrepreneur CREATE IMPACT.COM TRACKING LINKS USING PHP FUNCTIONS impact links

$accountSid – this is the account ID which you can find in the API section under Settings – API Settings
$authToken – this is the authentication token which you will also find in the API Settings page

The Simple Entrepreneur CREATE IMPACT.COM TRACKING LINKS USING PHP FUNCTIONS account sid auth token

$programId – this is the affiliate advertisers’ program ID number. You can find this on the brand page

Click on Brand – My Brands

The Simple Entrepreneur CREATE IMPACT.COM TRACKING LINKS USING PHP FUNCTIONS my brands

Click on the Brand

The Simple Entrepreneur CREATE IMPACT.COM TRACKING LINKS USING PHP FUNCTIONS my brands shopify

Click on More and then View and Manage Contract

The Simple Entrepreneur CREATE IMPACT.COM TRACKING LINKS USING PHP FUNCTIONS my brands shopify more
The Simple Entrepreneur CREATE IMPACT.COM TRACKING LINKS USING PHP FUNCTIONS my brands shopify view manage contract

You will then see the program id next to the brand name

The Simple Entrepreneur CREATE IMPACT.COM TRACKING LINKS USING PHP FUNCTIONS my brands shopify program id

I have added some code for debugging in particular the echo command to display the output of some of the variables. This allowed me to display any particular error messages, which was helpful. You just need to remove the comment remark // from the beginning of the line.

If this helps and you found this useful then please subscribe to my newsletter as I try to share helpful information to my audience.

Subscribe to my newsletter where I will share my journey in affiliate marketing, business, technology, fitness and life in general. Hopefully, this motivates you to also change your journey in life.

This field is required.

Subscribe to my newsletter where I will share my journey in affiliate marketing, business, technology, fitness and life in general. Hopefully, this motivates you to also change your journey in life.

This field is required.

If this article helped you in any way and you want to show your appreciation, I am more than happy to receive donations through PayPal. This will help me maintain and improve this website so I can help more people out there. Thank you for your help.

HELP OTHERS AND SHARE THIS ARTICLE


799Shares

LEAVE A COMMENT