How to target visitors by custom API parameters

This is an advanced feature and requires some programming knowledge. Please note that we are unable to provide support for creating or troubleshooting custom code.

You can find general instructions on how to work with Getsitecontrol API here.

You can use API targeting to display widgets based on certain information or properties in your web application logic.

_gscq.push(['targeting','{any-key}', '{any-value}']);

Let's say we want to target female paid users only. We should add the following method call somewhere in our template code after the Getsitecontrol script to pass the necessary parameters to Getsitecontrol API.

_gscq.push(['targeting','isPaid', '<%= user.isPaid %>']);
_gscq.push(['targeting','sex', '<%= %>']);

<%= …%> is an example of a template tag.

This code will set two parameters for widget targeting: isPaid and sex.

Then we need to configure the widget to understand these parameters. Open the necessary widget and switch to the Targeting tab. Choose the option visitors who meet the conditions below under Who should see this widget?, scroll down and click the + Add API parameter link.

Enter your custom parameters. In our example user.isPaid is a boolean value and can be male or female.

Click OK to save the changes.

That's it! This widget will now be shown to female paid users only.

Other articles you might find helpful: