Custom Data
Anything you already know when the page renders can travel with the page view. Put it on the <push-broom> element as an attribute starting with pb:.
<push-broom
url="/pricing"
pb:campaign="spring"
pb:cohort="A"></push-broom> Both campaign and cohort are recorded with that view, and both become things you can filter and group by. There is nothing to register first — a name you have never used before shows up once there is data carrying it.
Any number of attributes, any names you like. pb: is what marks an attribute as yours; without the prefix it is ignored.
Attributes or event()?
Attributes are for what your server already knows when it renders the page. pushbroom.event() is for what happens afterwards.
The same data lands in the same place either way, so the question is only ever which one you are in a position to use:
- The variant a visitor was served, the campaign that brought them, the category of the article: the page knows these at render time. Attributes.
- They clicked the button, they finished the form, the video reached the end: nobody knows these at render time.
event().
If you can do it with an attribute, do it with an attribute. It is markup rather than script, and it cannot fail to load.
Two things to watch
Names arrive lowercase. HTML lowercases attribute names, so pb:Campaign is recorded as pb:campaign. Write them lowercase and you will not be surprised later.
Values are read when the view fires, not before. On a site with client-side routing, a view is recorded when url changes — so if you are updating pb: attributes for the new page, update them along with url rather than after it, or the view carries the old ones.
Values
Short ones. Strings and numbers, the kind of thing that belongs in a filter list. A pb: attribute is a label on a page view, not somewhere to keep a record.
Do not put anything in here you would not want kept. Pushbroom writes these values to your storage exactly as given and never expires them — which is the same reason url is a path you choose rather than the one out of the address bar.
Last updated