Hello world

Home / Hello world
Below is some basic DimML code:
concept Global {
  match '*'  

  val url = `window.location.href`
  flow => debug 

  plugin script `console.log( 'Hello world' )`
  plugin debug
}
The code above does the following:

  • It defines a concept called “Global”
    • The concept encapsulates all the code within the accolades. That code is executed if the concept is successfully matched (see below).
  • The Global concept will match all URLs (‘*’). This means that the code within the Global concept is executed for all pages.
  • A variable called ‘url’ is created and set with the URL of the page where the code is executed
    • The code between back ticks ( `-symbol) is JavaScript that is executed in the visitor’s browser (client side)
    • All ‘vals’ that are created in this way are included in the DimML pixel request as a query string parameter
  • The script plugin enables client-side execution of JavaScript code placed between back ticks. This makes it easy to validate that an DimML application is running for a page
  • The debug plugin is necessary to allow the debug flow element to work

To verify that your code works as expected, publish and test your program (do this for all JavaScript code examples introduced below):

    1. Copy/paste the above code in the DimML sandbox
    2. Publish the program by entering a domain for which you want to test your DimML application and pressing publish
    3. A new tab will be opened with something like this added:

                                   ?dimml=sandbox/a9362c5d93b201d9925edf943a5a3ff61fb071a8

  1. Open the Javascript console (F12 in Chrome) to open the console. This should show the result of the processing by the DimML application:
Hello World
{url=http://www.yourdomain.com/}
If this message is available you have successfully created your first DimML application! Note that the value for url changes with each new page that is opened.