Placeholders are a Pro plugin feature that allows you to add dynamic data to event parameters.
When configuring custom events, you can add parameters (dimensions and metrics) to your tracking.
With placeholders, you can take it a step forward, and instead of using statically configured parameters, add dynamic or “site aware” information.
To use placeholders, just place them in the value field of a parameter. They can also be inserted with other text.
Placeholders are in the form of $$PLACEHOLDER$$ and will be replaced by the plugin when sending out an event.
You can see the list of placeholders if you click the “+” button next to the value:
Then click on the placeholder to add it to the value.
Available Placeholders #
PLACEHOLDER | DESCRIPTION |
---|---|
$$PAGENAME$$ | Name of the current page. |
$$REFERRER$$ | The address of the referrer (the previous page) |
$$ATTR_HREF$$ | Link URL |
$$ATTR_ALT$$ | atl HTML attribute (if exists) |
$$ATTR_TITLE$$ | title HTML attribute if exists |
$$ELEMENT_TEXT$$ | The tracked element’s text – for example, the text of a button. |
$$AUTHOR$$ | Post author. |
$$USER$$ | The name of the logged-in user. |
$$USER_ID$$ | The id of the logged-in user. |
$$IS_LOGGED_IN$$ | Is this a logged-in user – true or false. |
$$CATEGORY$$ | Page / Post category. |
$$PAGE_URL$$ | The URL of the current page. |
$$POST_ID$$ | The current page or post id. |
ATTR_ Placeholders #
There is also a special placeholder that allows you to include any attribute of an HTML element in the event data.
Anything you add after the $$ATTR_ can represent an HTML attribute of the clicked element.
For example, use $$ATTR_HREF$$ to grab a link’s href attribute (the link).
Or use $$ATTR_SRC$$ for an image file source.