.addBookmark()

Creates a Grow bookmark for the current page for the current reader.

The .addBookmark() method creates a Grow bookmark that is saved in a reader’s Grow profile. The method returns a Promise object that resolves if the action is successful (and rejects it if it does not).


Syntax

window.growMe.addBookmark(parameters)

Parameters

Name Type Description
source string optional

Used in Grow tracking so that the bookmark can be attributed to a particular place. It should identify the element or action that triggered the bookmark to occur (e.g. create-recipe-button).
tooltipReferenceElement HTMLElement optional

Grow shows a tooltip prompting a sign up on a reader’s first bookmark.

The tooltipReferenceElement specifies the HTML element to position the tooltip. This is typically set to the element that triggers the bookmark.

url string optional

Specifies the full URL of a page to bookmark on the current site.

Return Value(s)

  • A Promise object that is fulfilled if adding the bookmark succeeds. If it fails, the promise is rejected.

Example(s)

The following example creates an asynchronous function that tries to add a Grow bookmark. The tooltip is attached to the #custom-growme-bookmark-button HTML element. If the bookmark fails, an error handler catches the exception.

async function callAddBookmark() {
  try {
  	await window.growMe.addBookmark({ 
      source: "create", 
      tooltipReferenceElement: document.querySelector("#custom-growme-bookmark-button"),
      url: "https://www.mysite.com/page-to-bookmark/"
		});
	} catch (e) {
  	// Error handling.
	}
}