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 class | What it becomes on your site |
|---|---|
notifal-action-button | A clickable button (link, copy, close, add to cart, etc.) |
notifal-close-button | A dismiss control that closes the notification |
notifal-track-click | Marks 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>
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 value | Visitor experience |
|---|---|
post-link (default) | Opens the product, post, or page linked to the notification's content source |
copy | Copies text to the clipboard. Set data-copy-text="YOUR CODE" |
close | Closes the notification |
custom-trigger | Shows or hides elements on the page. Use data-show-elements and data-hide-elements with CSS selectors |
ajax-add-to-cart | Adds the product to the WooCommerce cart without leaving the page (WooCommerce required) |
custom | Opens 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-clickmanually 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:
| Class | What it shows |
|---|---|
notifal-post-feature-image | The 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:
| Attribute | Purpose |
|---|---|
data-preview-image-source | auto, product, post, page, order |
data-image-resolution | WordPress image size (default: large) |
data-image-lazy-load | true or false |
Block Editor and Elementor equivalents
If you prefer visual controls instead of CSS classes:
| HTML Builder class | Block Editor block | Elementor widget |
|---|---|---|
notifal-action-button | Action Button | Action Button |
notifal-close-button | Close Icon | Close Icon |
notifal-post-feature-image | Featured Image | Featured Image |
Checklist
- [ ] Close control uses
notifal-close-button - [ ] Main CTA uses
notifal-action-buttonwith the correctdata-notifal-action - [ ] Copy buttons include
data-copy-text - [ ] Custom links use
hrefordata-custom-url - [ ] Extra trackable links include
notifal-track-clickif needed
What to read next
HTML Builder series
- Creating a Template with the HTML Builder
- HTML Builder: Buttons, Close Icon, and Click Tracking (you are here)
- HTML Builder: AI Prompt Workflow
- HTML Builder: Layouts and Use Cases
- HTML Sanitization and Allowed HTML