Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guideDeveloper guideAdmin guide
Company siteHelp center
English
  • Русский
  • English
v72
  • v74
  • v73
  • v72
Login
  • User documentation
  • FAQ
  • Altcraft glossary
  • Profiles and databases
  • Communication channels
  • Segmentation
  • Message templates
  • Campaigns
  • Automation scenarios
  • Market
  • Loyalty programs
  • Reports and analytics
  • Integrations
  • Weblayers
    • Forms
    • Pixels
    • Pop-ups
      • Creating and publishing a pop-up
      • Setting up a popup in the code editor
      • Managing pop-ups manually via script
      • Popup analytics
      • Guide: pop-up for push subscriptions
    • Tag Manager
  • Settings
  • API requests: where to start
  • Changelog
  • library
This is documentation for Altcraft Platform v72. This documentation is no longer maintained.
The information for up-to-date platform version at this page is available (v74).
  • Weblayers
  • Pop-ups
  • Managing pop-ups manually via script
Documentation for version v72

Managing pop-ups manually via script

This guide is tailored for platform users who implement pop-ups on their site using scripts rather than the Altcraft Tag Manager.

Obtaining the script​

To obtain the script, go to the pop-up editor and in the additional actions menu, click on the icon :

In the new window, select the databases for profile search. When a user fills out the pop-up form, their data is sent to the platform. Then the platform checks if there is a profile with such data in one of the selected databases. If there is, the data of the existing profile is updated; if not, a new profile is created in the database.

Note that here you are setting the databases to search for existing profiles. User data, filled out in the pop-up form, will be imported into the database specified in the "Actions" section of the pop-up editor.

Click the "Show code" button. This code needs to be placed on the pages of the site where you want to show the pop-up. Further details on configuring the pop-up appearance logic are provided below.

Managing a popup via the script​

The following code is used to work with popups on the site:

<!-- Loading the script onto the page -->
<script>

(function (popupFunc) {
var script = document.createElement('script');
var firstScript = document.getElementsByTagName('script')[0];
window[popupFunc] = window[popupFunc] || function () {
(window[popupFunc].actions = window[popupFunc].actions || []).push(arguments);
};
window[popupFunc].last_init = 1 * new Date()
window['ACPopupFuncNamePlaceholder'] = popupFunc;
script.async = true;
script.src = 'https://pxl.altkraft.com' + '/popup/v1/js/popupLibrary.js';
firstScript.parentNode.insertBefore(script, firstScript);
})('acpopup');

</script>

<!-- Requesting pop-up data from the server + displaying the pop-up on the page -->
<script>

acpopup('create', '<popup_id>');
acpopup('show', '<popup_id>');

</script>

If you add this code to your site, the popup will be shown as soon as the page loads because of this script:

<script>
acpopup('create', '<popup_id>');
acpopup('show', '<popup_id>');
</script>

You'll need to set up how and when the pop-up appears.

Example 1. Pop-up appears 10 seconds after the page loads:

<script>
window.onload = function() {
setTimeout(function() {
// Запрос данных попапа с сервера
acpopup('create', '<popup_id>');

// Показ попапа
acpopup('show', '<popup_id>');
}, 10000);
};
</script>

Example 2. Pop-up appears when a button is clicked:

<button onclick="showPopupClick()">Show the pop-up</button>

<script>
function showPopupClick() {
acpopup('create', '<popup_id>');
acpopup('show', '<popup_id>');
}
</script>

To manage the pop-up, use the acpopup function. It has 3 modes:

  • create
  • show
  • sendEvent

create — request pop-up data from the server​

In the acpopup function you must pass the pop-up ID as the second argument. As the third argument you can pass* an object with information about matching* and SMID. The table describes the structure of this object:

ParameterTypeRequiredDescription
matching_modestringNoProfile search mode. It can be "email", "email_profile", "phone", "profile_id" or "custom".
matchingJSON objectNoAn object with one or two parameters: "search field": "field value" and "db_id": "database ID" — the array of the databases in which the profile should be searched. db_id can be omitted if the profile database is selected in the pop-up settings.
smidstringNoSend message ID

Example:

acpopup('create', 'AP-6eVbo2dP2Nnh0wtBp', {
matching_mode: 'email',
matching: {
email: 'john@example.com',
db_ids: [1]
},
smid: 'send_message_id',
})

show — show a pop-up to users​

In the acpopup function you must pass the pop-up ID as the second argument. The third argument can be object with onShow function, which will be called after the popup appears on the screen.

Example:

acpopup('show', 'AP-6eVbo2dP2Nnh0wtBp', {
onShow: function () {
console.log('Look at the screen')
},
})

sendEvent — send a pop-up custom event​

In the acpopup function you must pass the pop-up ID as the second argument. The third argument must be an object with custom event data. You can also pass matching data for a specific event and SMID to this object. The table describes the structure of the object:

ParameterTypeRequiredDescription
web_event_namestringYesEvent name
web_event_valueintNoNumeric value of the event
web_event_dataJSON objectNoObject with optional data for the event
matching_modestringNoProfile search mode. It can be "email", "email_profile", "phone", "profile_id" or "custom".
matchingJSON objectNoAn object with one or two parameters: "поле для поиска": "значение поля" and "db_id": "ID базы" — databases in which to search for a profile. db_id can be omitted if the profile database is selected in the pop-up settings.
smidstringNoSend message ID

Example:

acpopup('sendEvent', 'AP-6eVbo2dP2Nnh0wtBp', {
web_event_name: 'new_event',
web_event_value: 500,
web_event_data: {
status: 'active'
},
matching_mode: 'email',
matching: {
email: 'john@example.com',
db_ids: [1]
},
smid: 'send_message_id',
})
tip

If you're adding multiple pop-ups to one page, you only need to place the coode for loading script onto the page once, and then you can manage them using the acpopup function.

Last updated on Feb 16, 2024
Previous
Setting up a popup in the code editor
Next
Popup analytics
  • Obtaining the script
  • Managing a popup via the script
    • create — request pop-up data from the server
    • show — show a pop-up to users
    • sendEvent — send a pop-up custom event
© 2015 - 2025 Altcraft, LLC. All rights reserved.