Skip to main content

Tracking Script Customization

MaxConv tracking script provides various functions to extend its usage. The concept is to add a functions to the maxconv method. This function will execute your code after logging the visit. The following general template outlines how this function should appear:

maxconv(function (visitData) { 
// visitData object {campaign_id, tokens, click_id...etc}

// your code here
});

Once the tracking script is loaded with visit data, the following functions become available.

1. Get visitor's feature data like country, ISP...etc: maxconv("getFeatureData", function(featureData){ });

You can use this function to add more attractive elements to your lander.

<p>Special offer for <span id="isp"></span> user!</p>

<script>
maxconv(function(){
maxconv("getFeatureData", function(featureData){
document.getElementById("isp").innerText = featureData.isp;
});
});
</script>

2. Generate links: maxconv("generateLinks");

You can use this function to generate offer links and replace click URLs dynamically, for example, the CTA button with click URLs that were not present at the moment of loading script.

<script>
maxconv(function(){
//append CTA button
var result = document.getElementById("survey-result");
result.append('<a href="https://your-domain.com/click">Check Result</a>');

//generate links
maxconv("generateLinks");
});
</script>

3. Get Tokens: var tokens = maxconv("getTokens");

Use this function to retrieve traffic source tokens and campaign tokens. The return data is a object.

<script>
maxconv(function(){
var tokens = maxconv("getTokens");

//console.log(tokens)
// {
// //traffic source tokens
// t1: '...',
// t2: '...',
// t3: '...',
// t4: '...',
// t5: '...',
// t6: '...',
// t7: '...',
// t8: '...',
// t9: '...',
// t10: '...',

// //campaign tokens
// ct1: '...',
// ct2: '...',
// ct3: '...',
// ct4: '...',
// ct5: '...',
// }
});
</script>

4. Get the value of a parameter from the current URL: var countryParamValue = maxconv("getUrlParameter", "Required_Parameter_Name");

Use this function to fetch the parameter value, for example, with URL: https://some-lander.html?param-browser=Chrome

You can fetch the value of parameter "param-browser"

<script>
maxconv(function(){
var data = maxconv("getUrlParameter", "param-browser");

//console.log(data); //Chrome
});
</script>

5. Get offer links: var offerLink = maxconv("getOfferLink", Optional_Offer_Number);

This function allows you to get the offer link set in your MaxConv campaign and use it for your custom needs.

In case of a multi-offer lander, you can pass the offer number in this function in order to get a proper offer link.

<script>
maxconv(function(){
// redirect to offer page
window.location.href = maxconv("getOfferLink");

//or redirect to the second offer
// window.location.href = maxconv("getOfferLink", 2);
});
</script>

6. Log a click to server: maxconv("logClick", Optional_Offer_Number);

This function simply send a request to MaxConv server to register a click action.

<script>
maxconv(() => {
// register click
maxconv("logClick");

//then redirect to offer page
window.location.href = maxconv("getOfferLink");
});
</script>

7. Get Click ID: var clickId = maxconv("getClickId");

Retrive the click id, which can be used to attribute a conversion.

8. Log a conversion: maxconv("logConversion", Optional_Object_With_Payout_etc);

By using this function you can fire conversion postback with optionally payout, txid, event type...etc

<script>
//send a conversion postback when submit button is clicked.

var submitBtn = document.getElementById('submit-button');

submitBtn.addEventListener('click', function () {
maxconv(function() {
maxconv("logConversion", {
payout: 5,
event: "opt-in"
});
});
});
</script>

The optional object support all s2s postback parameters

9. Log a custom event goal: maxconv("logEvent", Optional_Event_Value);

This function send a request to MaxConv server to log a Custom Event Goal.

<script>
maxconv(function() {
//log the quiz finished goal when lander load
maxconv("logEvent", "quiz-finished");
});
</script>

FAQ

1. The function is not working, what to do?

The above functions is designed to extend the main tracking script, so you have to add the tracking script on the lander before custom function, here is a full example:

<!-- MaxConv Tracking Script Base Code-->
<script>!function(w,d,o,n,c){w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments)};var s=d.createElement(n),t=d.getElementsByTagName(n)[0];s.async=!0;s.defer=!0;s.src="https://your-domain.com/t/t.js";t.parentNode.insertBefore(s,t);}(window,document,"maxconv","script");</script>
<noscript><link rel="stylesheet" href="https://your-domain.com/t/t.css?mc_ns=1" /></noscript>
<!-- End MaxConv Tracking Script Base Code-->

<!-- Custom script-->
<script>
maxconv(function(){
var data = maxconv("getUrlParameter", "country");

//console.log(data); //United States
});
</script>