The JavaScript API screen is intended as a reference library for clients who need to integrate their own websites with Messaging. This screen provides sample JavaScript code that can be copied-and-pasted from the platform into your own site.
The JavaScript API screen provides sample code for the following features. These features are accessible from the Function Menu.
Getting Started: This sample code covers basic initialization, and is suitable for most use cases, such as implementing a Web Event, for example.
Google Analytics: This sample code is intended for clients who have integrated Google Analytics with Messaging. On this screen, you can select your Google Analytics Account. The sample code is then refreshed accordingly.
This sample code consists of two scripts. If your webpage already uses Google Analytics tracking, then you should omit the first <script> section; otherwise it should be included. Copy and paste the <script> section(s) just before the </body> tag of your webpage. Please note that this script includes the line:
_gaq.push(['_trackPageview']);
If your webpage already calls _trackPageview, then Google Analytics will count each visit twice. You should keep only the last _trackPageview call in your webpage code if the intention is to record each page hit only once.
Web Track: This sample code is intended for clients who are using Web Events to track consumer actions. On this screen, you can select a Web Event. The sample code is then refreshed accordingly.
The JavaScript API screen is accessible by the following method:
From the Main menu, select Data > Integration > JavaScript API