Limiting Access for a User to an Outgrow Content Piece for A Specific Time

Using this support document you will be able to get a better understanding of how you can make sure that your users only have access to an Outgrow content piece for a limited time period.

What are the Prerequisites for implementing this solution?

For implementing this solution in your account you need to have access to Custom Scripts as well as Custom Variables feature in Outgrow. Also, you should be able to pass the Current Time (in UNIX format) either using your ESP / CRM or using Custom Code as a solution in your own app.

How will this work in Outgrow?

When we implement this setup in Outgrow, we send the Current Time as a part of the Content URL to the user. When the user will access the Outgrow content piece for the first time, our Custom Script will evaluate the timestamp that is present in URL versus the time allotted. If there's time remaining, the users will be able to access the questions in the Outgrow content, but if the time has expired, the user will be redirected to some other page that can be specified by you. Here is an example of a content piece where this setup has been implemented:

A. An example where the link has expired.
B. An example where the link is still valid.

Lastly, here is the Custom JavaScript code that you need to add in your Outgrow content under the Configure tab:

var url = window.location.href;
var timestamp = getParameterByName('timestamp', url);
if(timestamp) {
    var old_date = new Date(timestamp*1000);
    var curr_date = new Date();
    var diff = Math.abs(curr_date.getTime() - old_date.getTime());
    diff = diff / (1000 * 60 * 60 * 24);
    if(diff>14) {
        window.location.href = "https://outgrow.co";
    }
    console.info('timestamp', timestamp);
    console.info('old_date', old_date);
    console.info('curr_date', curr_date);
    console.info('diff', diff);
}

function getParameterByName(name, url) {
    name = name.replace(/[\[\]]/g, '\\$&');
    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
        results = regex.exec(url);
    if (!results) {
        return null;
    }
    if (!results[2]) {
        return '';
    }
    return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

In case you have any questions or concerns, feel free to reach out to us at [email protected] and we will be happy to assist you further.