New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-bundled Script tag for visual editor #1773
Conversation
Your preview environment pr-1773-bttf has been deployed. Preview environment endpoints are available at: |
Deploy preview for docs ready! ✅ Preview Built with commit 32c1e80. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks solid, just one comment regarding documentation
Features and Changes
Thin wrapper around our javascript SDK for easier visual editor integration through GTM or other low-code tools.
TODO:
Basic Usage
This will instantiate a
GrowthBook
instance and callloadFeatures()
, kicking off any visual editor experiments.Default Attributes
The following attributes are set automatically:
id
- creates a long-livedgbuuid
cookie if it doesn't exist alreadyurl
path
host
query
deviceType
- eithermobile
ordesktop
browser
- one ofchrome
,edge
,firefox
,safari
, orunknown
utmSource
utmMedium
utmCampaign
utmTerm
utmContent
The UTM attributes are persisted in session storage so they will continue to be set even after page loads.
Default Tracking Callback
A default
trackingCallback
function will be set that fires bothanalytics.track
(Segment) anddataLayer.push
(GA4/GTM) events with the recommended event/property names.URL Updating
We will poll the page every 500ms to check for URL changes. If detected, it will call
gb.setURL()
and update any URL-related attributes.This is critical for SPAs since it allows visual editor experiments to reset and take effect automatically.
Customizing
In addition to passing context settings in
data-*
attributes, you can also define awindow.growthbook_config
object. This is useful for overriding non-string options liketrackingCallback
orattributes
. You can mix and match the two as well: