Create custom actions

You can create custom actions of your own using JavaScript. Once you define a custom action, you can reuse it within your document.

To create a custom action:

  1. Add a new event by clicking the Add event button at the bottom of the Events panel.
  2. Select the target and the event.
  3. For the action, select Custom > Add custom action. Google Web Designer prompts you to enter your custom code.
  4. Name the action in the field above the code box (after the gwd. prefix).
    • Each custom action must have a unique name within the document.
    • The name should be descriptive enough to be recognizable.
    • If you enter an invalid name (such as a name that includes spaces), the field is underlined in red.
  5. Define the function in the code box. Refer to the Component APIs for a list of properties, events, and methods available for each component.
  6. Click OK.

The event is configured to use your custom action. This action is also now available to use for other events, listed under Custom.

You can resize the dialog box by dragging the bottom right corner.

Examples

Custom actions can be used along with components to extend the functionality of Google Web Designer. The following examples all use the document.getElementById method to specify the element in the document that the action applies to.

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Main menu
7427512025068209298
true
Search Help Center
true
true
true
true
true
5050422
false
false
false
false