Controling ActivEngage
To take customization even further, ActivEngage offers tools that allow you some control over our analytics and widgets on your site.
Visibility
There may be times when you want to control whether the widets are shown or hidden. One example might be that you want to hide the ability to chat until the customer has accepted the terms of your site. To do that, you would call hide(); and then after acceptance you would call show(); (examples below).
widgets.hide
ActivEngage.widgets.hide();
widgets.show
ActivEngage.widgets.show();
Rebind
Many pages will load data after the initial load of the page. For example, vehicle search results. You may load part of the dealership's inventory at first, but in the interest of speed you wait to load the more of inventory until the customer has started to scroll. If in that case you use the data attributes chat-launch on an individual vehicle element the ActivEngage script will NOT detect this change. To pick up these new elements rebind(); must be called. This function can be called as much as needed for PageView to pick up any new elements added to the page.
rebind
ActivEngage.rebind();
SPA Controls
This group of functions was designed specifcally to help SPA apps. Many modern web applications today are SPA apps. These apps don't naviagate the way most dealer websites do. This can cause a few problems with a script like ours. Without a page navigation event our script will not update it's bindings for attributes like chat-account, chat-launch, chat-data, and etc. To help with this we have a series of functions that should address these issues.
spacontrol.stop
Can only be called if the ActivEngage script is currently in a running state (which it is by default upon loading). This command complete shutsdown the ActivEngage script and forces it to unload any customization modules that it maybe loaded for current chat-account. All listeners should also be removed as well. The benefit of this is that when run(); is called in the future it will have a clean slate to work with.
ActivEngage.spacontrol.stop();
spacontrol.run
Can only be called if the ActivEngage script is current NOT in a running state (after stop(); is called for example). This command relaunches the ActivEngage PageView script. All params and attributes are re-evaulated at this point.
An example use case of this might be if you need to change the chat-account. You would call stop(); the ActivEngage script would unload. Then you could update the chat-account value. Once ready you could then call run(); and the ActivEngage PageView script would load all the widgets for the new account specified.
ActivEngage.spacontrol.run();
When to use show/hide vs stop/run.
Above we've given two very different approaches to turning on/off the ActivEngage widgets. For merely controlling whether a widget is presented to the customer or not show/hide is the preferred method. This allows the AE script to continue running in the background and will provide the most complete picture to the Agent when the customer decides to engage in a conversation.
stop/run should really only be used in cases of a SPA app where the customer might navigate to a page that shouldn't have chat on it at all. Or when the customer might navigate to a page that has a different chat-account present.