<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ayla Prinz</title>
    <description>The latest articles on DEV Community by Ayla Prinz (@aylaju).</description>
    <link>https://dev.to/aylaju</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F877615%2Fc127a8d5-2512-4fee-bf97-d12877fa8054.jpg</url>
      <title>DEV Community: Ayla Prinz</title>
      <link>https://dev.to/aylaju</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aylaju"/>
    <language>en</language>
    <item>
      <title>Webflow + Walker.js</title>
      <dc:creator>Ayla Prinz</dc:creator>
      <pubDate>Thu, 24 Nov 2022 10:51:17 +0000</pubDate>
      <link>https://dev.to/walkerjs/webflow-walkerjs-1oml</link>
      <guid>https://dev.to/walkerjs/webflow-walkerjs-1oml</guid>
      <description>&lt;p&gt;&lt;em&gt;The perfect match when it comes to tracking events for Google Tag Manager in Webflow.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To track user behavior on a Webflow site, the typical options involve manually coded dataLayer scripts with custom HTML on each page or using CSS selectors via the Google Tag Manager interface. If neither of these really work for you, try using walker.js for user behavior tracking based solely on &lt;strong&gt;custom attributes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Walker.js is a light-weight JavaScript library for capturing first-party user behavior data &lt;strong&gt;directly in HTML markup&lt;/strong&gt;. It offers the developer’s experience and flexibility of big analytics libraries like Segment's analytics.js but, crucially, remains much simpler than it through a &lt;strong&gt;declarative approach&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Walker.js code lives directly in element attributes, and that makes it a perfect fit for Webflow sites.&lt;/p&gt;

&lt;p&gt;So, how can you integrate and use walker.js in Webflow?&lt;/p&gt;

&lt;h1&gt;
  
  
  Initializing walker.js
&lt;/h1&gt;

&lt;p&gt;To initialize walker.js in Webflow, include the following script tag in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element globally in Project Settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;async&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"elbwalker"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.jsdelivr.net/npm/@elbwalker/walker.js@latest/dist/walker.js"&lt;/span&gt; &lt;span class="na"&gt;data-default=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please refer to the Webflow docs article “&lt;a href="https://university.webflow.com/lesson/custom-code-in-the-head-and-body-tags" rel="noopener noreferrer"&gt;How to add custom code to Webflow&lt;/a&gt;” to learn more about custom code in Webflow.&lt;/p&gt;

&lt;h1&gt;
  
  
  Adding elb-tags via custom attributes
&lt;/h1&gt;

&lt;p&gt;Walker.js events are declared as custom element attributes. To add a custom attribute to an element in Webflow Designer go to the Element Settings tab and click the plus icon on the custom attributes panel:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.loom.com/share/7f04035b7cfd4e4e94dd5b87dd2eaa19" rel="noopener noreferrer"&gt;&lt;br&gt;
    &lt;p&gt;Add custom attributes in Webflow - Watch Video&lt;/p&gt;
&lt;br&gt;
    &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.loom.com%2Fsessions%2Fthumbnails%2F7f04035b7cfd4e4e94dd5b87dd2eaa19-1669129520380-with-play.gif" width="576" height="360"&gt;&lt;br&gt;
  &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article, custom attributes will be described as follows:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;data-elb="ENTITY"&lt;br&gt;
  data-elb-ENTITY="KEY:VALUE"&lt;br&gt;
  data-elbaction="TRIGGER:ACTION"&lt;br&gt;
  data-elbglobals="KEY:VALUE"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;which corresponds to the following settings in Webflow Designer:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F33bfegt38yle60lrghcg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F33bfegt38yle60lrghcg.png" alt="elb-attributes in Webflow" width="475" height="346"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Walker.js example: tagging banner engagement
&lt;/h1&gt;

&lt;p&gt;In this short tutorial, say you want to track the engagement of a user with a promotion banner using walker.js.&lt;/p&gt;

&lt;p&gt;We want to measure how often the promotion banner has been visible to your users. How many times the "Get started"-button got hovered over and how many clicks happened on both the "Get started" and "book demo"-button. &lt;/p&gt;
&lt;h3&gt;
  
  
  Setting the scope and properties of the banner
&lt;/h3&gt;

&lt;p&gt;To set the scope of what element we want to track the first thing we do is set the entity.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;data-elb="banner"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We also want to add a property that further describes the entity e.g. title or the headline we used. This way we can later test different titles against each other for example.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;data-elb-banner="title:Example Banner"&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Measure visibility of the banner
&lt;/h3&gt;

&lt;p&gt;Add the action attribute and use the trigger &lt;code&gt;visible&lt;/code&gt; which fires the view event after the element has been in the user's viewport for at least 50% for one second.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;data-elbaction="visible:view"&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
The config should look like this at this point:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb5g05l8ri7k72jypbbq2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb5g05l8ri7k72jypbbq2.png" alt="Config of custom elb-attributes in Webflow" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Measure mouse hover &amp;amp; click events
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;data-elbaction="hover;click:start"&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk3taqormv55sm8rsllm8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk3taqormv55sm8rsllm8.png" alt="Config of custom elb-attributes in Webflow clicks and hover" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;data-elbaction="click:demo"&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxuncvysh4x4yb17naawh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxuncvysh4x4yb17naawh.png" alt="Config of custom elb-attributes in Webflow clicks" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many more prebuilt triggers like pulse, load, and wait  ...&lt;a href="https://docs.elbwalker.com/tagging/available-triggers" rel="noopener noreferrer"&gt;See the full list&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Set global attributes to every user interaction
&lt;/h3&gt;

&lt;p&gt;Global attributes give more context to the data. Setting an elb-global attribute for page types e.g. helps to differentiate between the same events happening on different page types. We used the home and features type in this example. Global attributes can simply be added e.g. to the &lt;code&gt;body div&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;data-elbglobals="pagetype:home"&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;code&gt;data-elbglobals="pagetype:features"&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F007ebsxgkehgnokgrpe6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F007ebsxgkehgnokgrpe6.png" alt="Custom global elb-attributes in Webflow" width="800" height="117"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Debugging in the console
&lt;/h1&gt;

&lt;p&gt;To be able to debug the implementation in the console we’ll add the “console destination” in the custom code settings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;elb&lt;/span&gt;&lt;span class="p"&gt;(){(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;elbLayer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;elbLayer&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[]).&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);}&lt;/span&gt;
&lt;span class="nf"&gt;elb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;walker destination&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.loom.com/share/0b9048f512c449158e5e9ffcaa669000" rel="noopener noreferrer"&gt;&lt;br&gt;
    &lt;p&gt;Testing walker.js implementation in Webflow - Watch Video&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
    &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.loom.com%2Fsessions%2Fthumbnails%2F0b9048f512c449158e5e9ffcaa669000-1669130359847-with-play.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.loom.com%2Fsessions%2Fthumbnails%2F0b9048f512c449158e5e9ffcaa669000-1669130359847-with-play.gif" width="576" height="360"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
  &lt;/p&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;There you have it — walker.js in Webflow!&lt;/p&gt;

&lt;p&gt;By having full events in the dataLayer you can further use them in Google Tag Manager. You can e.g. use them as events for Google Analytics 4 or as conversion events for the Meta pixel.&lt;/p&gt;

&lt;p&gt;This is just the beginning of a small Webflow series — please let me know what user interactions you want to measure with walker.js in Webflow.&lt;/p&gt;

&lt;p&gt;Links:&lt;/p&gt;

&lt;p&gt;Documentation: &lt;a href="https://docs.elbwalker.com" rel="noopener noreferrer"&gt;https://docs.elbwalker.com&lt;/a&gt;&lt;br&gt;
More examples: &lt;a href="https://www.elbwalker.com/gallery" rel="noopener noreferrer"&gt;https://www.elbwalker.com/gallery&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/elbwalker/walker.js" rel="noopener noreferrer"&gt;https://github.com/elbwalker/walker.js&lt;/a&gt;&lt;br&gt;
LinkedIn: &lt;a href="https://linkedin.com/elbwalker" rel="noopener noreferrer"&gt;https://linkedin.com/elbwalker&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
