HTML Builder

HTML Builder: Buttons, Close Icon, and Click Tracking

4 min read

In the HTML Builder you design buttons and close icons like any other HTML element. Notifal recognizes a few special CSS classes and turns them into working controls: dismiss the notification, open links, copy text, add to cart, and record clicks in analytics.

The Block Editor and Elementor have dedicated blocks/widgets for the same features. If you use those editors instead, see Notifal Gutenberg Blocks Reference or Notifal Elementor Widgets Reference.

The three class names to know

CSS classWhat it becomes on your site
notifal-action-buttonA clickable button (link, copy, close, add to cart, etc.)
notifal-close-buttonA dismiss control that closes the notification
notifal-track-clickMarks an element for click tracking in analytics

You do not need to add notifal-track-click yourself on action buttons. Notifal adds it automatically when it processes notifal-action-button.

Close icon (notifal-close-button)

Add any element (often a <div> or <span>) with the class notifal-close-button. Style it however you like (X icon, text, image background).

What Notifal does automatically:

  • Makes it keyboard accessible
  • Adds a "Close Notification" label for screen readers
  • Records close events in analytics when visitors dismiss the notification

Example

<div class="notifal-close-button" style="position:absolute;top:8px;right:8px;">✕</div>
Tip: Place the close control in a corner where visitors expect it (top-right is common).

Action button (notifal-action-button)

Add a <a> or <button> element with the class notifal-action-button. Notifal wires it up for tracking and behavior.

What Notifal adds automatically:

  • Click tracking class (notifal-track-click)
  • A unique tracking ID for analytics
  • Default accessibility label

Choose what the button does

Set the action with data-notifal-action or data-link-type:

Action valueVisitor experience
post-link (default)Opens the product, post, or page linked to the notification's content source
copyCopies text to the clipboard. Set data-copy-text="YOUR CODE"
closeCloses the notification
custom-triggerShows or hides elements on the page. Use data-show-elements and data-hide-elements with CSS selectors
ajax-add-to-cartAdds the product to the WooCommerce cart without leaving the page (WooCommerce required)
customOpens a custom URL. Set href or data-custom-url

Examples

Link to the product in context:

<a class="notifal-action-button" data-notifal-action="post-link">Shop now</a>

Copy a coupon code:

<a class="notifal-action-button" data-notifal-action="copy" data-copy-text="SAVE20">Copy code</a>

Custom URL:

<a class="notifal-action-button" data-notifal-action="custom" href="https://example.com/sale">View sale</a>

Click tracking (notifal-track-click)

Notifal counts button clicks in OnPage Analytics. Any element with the class notifal-track-click is included.

  • Action buttons: Notifal adds this class for you when you use notifal-action-button.
  • Custom links: Add notifal-track-click manually to any clickable element you want tracked.

Example: track a custom link

<a href="https://example.com" class="notifal-track-click">Learn more</a>

View results under Notifal → OnPage Analytics.

Featured image placeholder (notifal-post-feature-image)

While editing buttons, you may also use an image placeholder class:

ClassWhat it shows
notifal-post-feature-imageThe featured image from the notification's context (product, post, order, etc.)

Leave the element empty. Notifal fills in the image on the front end.

Optional attributes:

AttributePurpose
data-preview-image-sourceauto, product, post, page, order
data-image-resolutionWordPress image size (default: large)
data-image-lazy-loadtrue or false

Block Editor and Elementor equivalents

If you prefer visual controls instead of CSS classes:

HTML Builder classBlock Editor blockElementor widget
notifal-action-buttonAction ButtonAction Button
notifal-close-buttonClose IconClose Icon
notifal-post-feature-imageFeatured ImageFeatured Image

Checklist

  • [ ] Close control uses notifal-close-button
  • [ ] Main CTA uses notifal-action-button with the correct data-notifal-action
  • [ ] Copy buttons include data-copy-text
  • [ ] Custom links use href or data-custom-url
  • [ ] Extra trackable links include notifal-track-click if needed

What to read next

HTML Builder series

  1. Creating a Template with the HTML Builder
  2. HTML Builder: Buttons, Close Icon, and Click Tracking (you are here)
  3. HTML Builder: AI Prompt Workflow
  4. HTML Builder: Layouts and Use Cases
  5. HTML Sanitization and Allowed HTML

Other template editors