Skip to main content

Dynamic urls for redirects / Template urls

To redirect into dynamic urls, i.e. urls that change based on some user attribute, you can use template urls where you define which user attribute to use in the url and we will then replace it with correct value for each user.

For template urls to work, you have to first identify users

Let's say you have an url like https://example.com/some_user_id_9809/dashboard where the "some_user_id_9809" is dynamic and will change for every user.

In your code you would have setup user identification, like explained at identify users, for example:

window.onload = () => {
window.Produktly.identifyUser("some_user_id_9809", {
plan: "startup",
companyId: 42,
createdAt: "2021-10-26T12:33:52Z",
});
};

In Produktly you can then define your url as: "https://example.com/{user.id}/dashboard". Produktly will then know how to replace the template variable with the correct values based on the data you provided with window.Produktly.identifyUser function.

More complicated paths work too, e.g. http://example.com/{user.permissions[0].action}. Just make sure that anything after "user.", should be a value in the metadata object you have provided.