Guide
Priceers has a public API endpoint to get the active campaign data. This endpoint can be used both on the server or the client (user's browser) based on your applications' needs. However, we suggest to use it on the client side in order not to decrease the page speed.
Simple API call
Below is a simple Javacsript code to make the call.
const appId = "clgebjynu0000cazgt50q0asd";
const queryString = window.location.search;
const searchParams = new URLSearchParams(queryString);
fetch("/api/client", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
appId: appId,
overrideSecret: searchParams.get("overrideSecret"),
overrideCampaignId: searchParams.get("overrideCampaignId"),
overrideDate: searchParams.get("overrideDate"),
}),
})
.then((response) => response.json())
.then((data) => {
console.log("Success:", data);
})
.catch((error) => {
console.error("Error:", error);
});
Note that it captures the override
parameters from the URL and pass it to
the API. This enables to easily test the campaigns.
Testing
It is usefull to test campaigns before their actual date or before activating them. Priceers API provides override
parameters to secretly get any campaigns created on the Priceers Dashboard.
Override parameters are: overrideSecret
, overrideCampaignId
and overrideDate
. Please refer to the API page for their formats. Because the formats of these variables are URL friendly, if you use the api logic above, you can send these variables to the api with URL parameters.
All campaigns have a test button on your Dashboard. When clicked, your dashboard will redirect you to your domain with the neccessary URL paramters to test the campaign automatically. However, you need to implement above logic for this to work.
You can also manually test via changing the URL parameters yourself. Below are some URL parameter examples for overrides.
Test Any Campaign
Below URL parameters can be used to test any (activated/deactivated) campaign.
?overrideSecret=superSecretToken&overrideCampaignId=clgfrcc8n00069oca6pd94zvb
Test via simulating a date
Below URL parameters can be used to test to get the active campaign at any point in time.
?overrideSecret=superSecretToken&overrideDate=2023-04-14T15:30:00Z