# How to Track Micro Conversions

SMSGenius enables you to track contacts who perform specific actions on your landing page or website, allowing you to create targeted audience segments based on these interactions. 🕵️‍♂️

We refer to these actions as 'micro-conversions.' A micro-conversion could be an action like adding an item to a shopping cart 🛒, or clicking on a specific button or link 👆 on your landing page.

To track these micro-conversions, simply implement the following JavaScript snippet:

<script>
function getParameters(url) {
    var questionMarkIndex = url.indexOf('?');
    if (questionMarkIndex !== -1) {
        url = url.slice(questionMarkIndex + 1);
    }

    var parameters = url.split('&');
    var parametersObject = {};

    parameters.forEach(function (parameter) {
        var parts = parameter.split('=');
        var key = decodeURIComponent(parts[0]);
        var value = decodeURIComponent(parts[1]);
        parametersObject[key] = value;
    });

    return parametersObject;
}

function executeOnClick() {
    let params = getParameters(window.location.href);
    let cid = params['cid'];

    // Check if 'cid' exists
    if (cid) {
        fetch("https://postback.smsgenius.io/?cid=" + cid + "&txid=TRIGGERED&payout=&currency=&user_agent=&ip_address=").then(function(response) {
            console.log(response);
            response.json().then(function(r) {
                // ACTION AFTER TRANSMISSION
            });
            return response.blob();
        }).then((myBlob) => {
            console.log(myBlob);
        });
    } else {
        console.log("Parameter 'cid' not found.");
    }
}

document.getElementById('myMicroConversion').addEventListener('click', function(event) {
    executeOnClick();
});
</script>

This snippet should be inserted just before the closing </body> tag of your webpage.

Then, to start tracking, simply add id=myMicroConversion to the element you wish to monitor (be it a link, button, or any other interactive element). This will enable you to track all contacts who interact with that specific element.

It's that easy!