Last active
September 7, 2022 21:22
-
-
Save jcoryalvernaz/43285b7455b0b2832e46a2a747b44f5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
//<![CDATA[ | |
setTimeout(function() { | |
// Get the name for the Parsely visitor cookie | |
const parselyVisitorCookieName = PARSELY.visitorManager.visitorCookieName || '_parsely_visitor'; | |
// Construct the visitor object with hidden fields passed to the form | |
const parselyVisitor = { | |
id: "%%parsely_visitor_id{js}%%", | |
session_count: parseInt("%%parsely_visitor_session_count{js}%%", 10), | |
last_session_ts: parseInt("%%parsely_visitor_last_session_ts{js}%%", 10), | |
}; | |
// Set the Parsely visitor cookie within the iframe | |
PARSELY.ParselyStorage.setJSON(parselyVisitorCookieName, parselyVisitor, { sameSite: 'none', secure: true }); | |
// Manually trigger the conversion event with the type and label passed to the form | |
PARSELY.beacon.trackPageView({ | |
url: "%%parent_url{js}%%", | |
action: 'conversion', | |
data: { _conversion_type: "%%parsely_conversion_type{js}%%", _conversion_label: "%%parsely_conversion_label{js}%%" }, | |
}); | |
// Get the redirect from the Pardot hidden fields | |
// Setting the redirect in the Pardot UI causes a race condition with this code | |
const redirectUrl = "%%redirect_url{js}%%"; | |
if (redirectUrl) { | |
top.location = redirectUrl; | |
}; | |
}, 200); | |
//]]> | |
</script> |
@jcoryalvernaz for the lines using
parseInt
, remember to add theradix
argument:session_count: parseInt("%%parsely_visitor_session_count{js}%%", 10), last_session_ts: parseInt("%%parsely_visitor_last_session_ts{js}%%", 10),
👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jcoryalvernaz for the lines using
parseInt
, remember to add theradix
argument: