Reports

Why do I get an error when creating an event with the events bookmarklet?

Last updated: October 6, 2015

When creating an event using the events bookmarklet, you may receive the following error message: "We couldn't create a selector for you. Please put an ID closer to the element you'd like to attach this event to."

Events bookmarklet error
Events bookmarklet error

The bookmarklet creates events by determining a jQuery selector from the HTML of the element to be tracked.

  • When an item has the same selector as another element on the page already associated with an event, the bookmarklet will result in the above error. A common example is multiple bulleted lists within the same div tag.
Duplicate bulleted items
Duplicate bulleted items
  • In this example, the bookmarklet is unable to distinguish the selector for the bulleted item from list 1 ("For spelling out benefits and") from the bulleted item from list 2 ("Search our user guides").
  • Both elements are found to have the same jQuery selector: span#hs_cos_wrapper_right_column.hs_cos_wrapper.hs_cos_wrapper_widget.hs_cos_wrapper_type_rich_text > ul > li:eq(1)

For these types of similar elements, we recommend manually adding an id tag to the elements to ensure that the bookmarklet is able to find a unique identifier.

  1. Navigate to the HTML or source code of your page.
  2. Search for your elements that are causing the bookmarklet error and add: id="unique_id" to each item.
Add id tags to HTML
Add id tags to HTML

Once the unique id tags are added and the page is updated, use the bookmarklet to pull in this id as the identifier and successfully create the events.

  • Ex. Generated event for bulleted item from list 1:
Unique id for bulleted item 1
Unique id for bulleted item 1
  • Ex. Generated event for bulleted item from list 2:
Unique id for bulleted item 2
Unique id for bulleted item 2