To use analytics in your asset you must import the SAM frontend javascript library. You can use the following link to import or download the library:
<script src=“https://files.interact.technology/code/itsam/itSam-latest.js"></script>
Once this library is imported into your project you can then use the sendPingAnalytic function to send an analytic event from your asset which can be used to track page views or other events that need to be tracked.
The sendPingAnalytic function takes in 3 parameters - identifier, subcomponent, subsubcomponent
This library and analytics function will work on both MI App and MI Desktop.
const samCallbacks = { initialize: function() { console.log('itSam.callbacks.initialize();'); }, appInfo: function() { console.log('itSam.callbacks.appInfo();', itSam.appInfo); }, authToken: function() { console.log('itSam.callbacks.authToken();'); }, error: function() { } }; itSam.initialize(null, samCallbacks);
itSam.sendPingAnalytic("/product"); itSam.sendPingAnalytic("/product", "ACTION", "Save"); itSam.sendPingAnalytic("/product", "SEARCH", "myterm"); <!-- Copyright (c) 2021 The Interact Technology Group. THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. All rights reserved. —>
To ‘ping’ a page/view as being shown, call the function with a path/identifier.
The sub-component and subsub-component are optional (pass "" if not used) which allows for more granular tracking data to be collected.
For a working example download the test asset below.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article