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
$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
$programId – this is the affiliate advertisers’ program ID number. You can find this on the brand page
Click on Brand – My Brands
Click on the Brand
Click on More and then View and Manage Contract
You will then see the program id next to the brand name
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.
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
LEAVE A COMMENT
I am an entrepreneur based in Sydney Australia. I was born in Vietnam, grew up in Italy and currently residing in Australia. I started my first business venture Advertise Me from a random idea and have never looked back since. My passion is in the digital space, affiliate marketing, fitness and I launched several digital products. You will find these on the portfolio page.
I’ve decided to change from a Vegetarian to a Vegan diet and started a website called Veggie Meals.
I started this blog so I could leave a digital footprint of my random thoughts, ideas and life in general.
If any of the articles helped you in any way, please donate. Thank you for your help.
Affiliate Compensated: there are some articles with links to products or services that I may receive a commission.