Embedding with JavaScript

Embedding with JavaScript is slightly more complicated and requires two steps:

  1. Add the JavaScript Source to <head>
  2. Insert code in the <body> where the element should appear

NOTE: The format of screens is slightly different in Version 3.

Embed Codes Pop-up

Embed Codes Pop-up
  1. Check that "JavaScript" is selected
  2. Select the view you wish to embed
  3. Specify whether you want to include navigation to Metric Insights
  4. Copy the script source code to the <head> section of your page
  5. Copy and paste the JavaScript code to the <body> of your page where you want the element to appear


The Metric Insights JavaScript Demo is a little more complex than a simple copy and paste of code.  We added a drop box that calls a function so we can easily switch between elements.

JavaScript Source in <head>

function switchElement()

function switchElement()

We created a function in the <head> of the sample page for switching out the different elements in our drop box (see below).

Drop box select_element

Next we created a drop box with a list of Elements.  Note that there is an "onChange()" action that calls the "switchElement()" function created above.

JavaScript code in the <body>

This is the code in the body of the page and should look similar to the code you see in the Embed Codes dialog box.

Sample Page

Sample Page