Script
To quickly try it out, you can also load the latest default walker.js
configuration via CDN. Add the script tag to the <head>
of your HTML file.
- Scripts
- Module
The walker.js
script creates a global walkerjs
and elb
automatically.
<script
async
class="walkerjs"
src="https://cdn.jsdelivr.net/npm/@elbwalker/walker.js@latest/dist/walker.js"
data-default="true"
data-version="1"
></script>
<script>
function elb() { (window.elbLayer = window.elbLayer || []).push(arguments); }
</script>
Using data-default="true"
adds the dataLayer
as a default destinations and
starts the walker automatically. With data-version
the current tagging version
can be set. In both cases class="walkerjs"
is required to identify the
script tag to check for the attributes.
In most of the examples, you'll find the imported elb
function. The hosted
browser version also comes with it but should be loaded async. Add the following
snippet manually in addition to the script:
Load the .mjs
module-file directly from the CDN or your own server.
<script type="module">
window.elb = (...args) => {
(window.elbLayer = window.elbLayer || []).push(...args);
};
const WalkerJs = (
await import(
'https://cdn.jsdelivr.net/npm/@elbwalker/walker.js@latest/dist/index.mjs'
)
).default;
window.walkerjs = WalkerJs({});
</script>
Be aware of the latest
version in the URL, better use a specific version like
3.0.0
It's recommended to use the externally hosted version only for demo purposes and not in production.