Dynamic Values
On this pageShowHide

Dynamic Values

HTML
<script>
  window.getMeta = function (property) {
    var meta = document.querySelector('meta[property="' + property + '"]');
    return meta ? meta.getAttribute('content') : null;
  };

  SP.go('productPage', {
    productId: "PRODUCT_ID",
    product: "$getMeta,og:title",
    link: "$getMeta,og:url",
    image: "$getMeta,og:image"
  });
</script>

Sometimes you can’t put real data into a snippet, e.g. when it is added by a Tag Manager. Instead, you can give a value that names a function: Trustisto calls it and uses the result.

$-prefixed values

A string value that starts with $ is evaluated:

  • "$myFunction" calls window.myFunction()
  • "$myObject.getName" calls window.myObject.getName() (dots go down the object path)
  • "$myFunction,arg1,arg2" calls window.myFunction("arg1", "arg2"). Arguments are passed as strings, up to 4 of them.

Values are evaluated in the params of Add To Basket, Remove From Basket, Basket Page, Save Basket, the basket of the Thank You Page and in events, including Product Page and Custom Events.

You can also evaluate a value yourself, e.g. to call a function once the library is loaded:

HTML
<script>
  SP.go('ev', '$myFunction,arg1');
</script>