Skip to content

Conversation

@marinhero
Copy link
Contributor

@marinhero marinhero commented Sep 10, 2021

What does this PR do?

Deprecates the Marketo associateLead and uses the recommended method of MktoForms2 instead.

Are there breaking changes in this PR?

Marketo will be removing associateLead in October. If customers don't take preemptive actions to start using forms, their calls to identify will be showing a message in the console:

'Invalid settings for identify method. Please review your Marketo V2 destination settings.'

Customer comms and doc updates are in progress to mitigate the hard cutover.

Testing

  • Testing completed successfully using the analytics.js-integrations compiler connected to stage.

Does this require a new integration setting? If so, please explain how the new setting works

Yes, two:

  • marketoFormId: every form in Marketo has an ID. We need customers to provide their form ID so we can pull it and use the form in calls to identify.
  • marketoHostUrl: the forms we will be using are relative to a domain. We need customers to provide their host URL so we can fetch the form from the right host.

Both settings are strings, available via CDN, and not required since track can work without them.

Links to helpful docs and other external resources

*/

Marketo.prototype.initialize = function() {
var self = this;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to reassign this to self here. When passed as an argument to a method (as on line 108), this should still refer to the outer context (in this case, the initialize prototype method).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that only apply if you are trying to access this itself inside of the function? All I'm doing on 108 is to pass a reference to the value inside the options object. Options become available via the scope of the function (this).

I'll move the reasign below the variable definitions but please let me know what you think.

.option('host', 'https://api.segment.io')
.option('accountId', '')
.option('projectId', '')
.option('traits', [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add the marketoFormId option somewhere here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I'm not sure but I will learn about this. There's also marketoHostURL and it should be added in here as well

var url = require('component-url');
var when = require('do-when');
var each = require('@ndhoule/each');
var onBody = require('on-body-ready');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we simply write our own helper method rather than install a third-party package. The relevant code looks to be about ~10 lines or so. Can we copy/paste?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I was just following a pattern I saw in another integration but I'd rather not use a dependency. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out load will be enough to make sure the form library is ready to work! we don't need to bring anything in 😎

@marinhero marinhero marked this pull request as ready for review September 11, 2021 00:32
};

Marketo.prototype.setupAndSubmitForm = function(traits, form) {
console.log('PRIME')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to keep this console.log ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, this was for testing purposes. My bad!

});

this.load('forms', { marketoHostUrl: marketoHostUrl }, function() {
var marketoForm = document.createElement('form');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we only create the form id marketoHostUrl is defined ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a validation for that already. The code won't reach this point if marketoHostUrl is undefined

"@segment/analytics.js-integration-gtag": "file:../integrations/gtag",
"@segment/analytics.js-integration-gosquared": "file:../integrations/gosquared",
"@segment/analytics.js-integration-heap": "file:../integrations/heap",
"@segment/analytics.js-integration-hellobar": "file:../integrations/hellobar",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These deletes seem unrelated to your changes, do we need them in this PR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it's cleanup work but I think we should keep them. Otherwise, people will always have to troubleshoot the compiler before being able to start working.

@marinhero marinhero force-pushed the marin/marketo-associateLead-deprecation branch from 1b66d5e to 4542428 Compare September 13, 2021 20:31
@brennan
Copy link
Contributor

brennan commented Sep 13, 2021

@marinhero Is it possible to share, either directly in the PR comment or in a linked paper doc, the manual testing you did using the compiler tool?

Marketo.prototype.setupAndSubmitForm = function(traits, form) {
form.addHiddenFields(traits, form);
// Do not remove this callback. This ensures there are no page refreshes after the form is submitted.
form.onSuccess(function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an onFailure callback to not refresh in that scenario either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@lcampos lcampos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending the couple of changes we talked about earlier

@marinhero marinhero force-pushed the marin/marketo-associateLead-deprecation branch from a0bb739 to 62c770c Compare September 17, 2021 19:32
@marinhero marinhero force-pushed the marin/marketo-associateLead-deprecation branch 3 times, most recently from 25b973e to 630b43c Compare September 27, 2021 16:51
@marinhero marinhero force-pushed the marin/marketo-associateLead-deprecation branch from 630b43c to c62b13e Compare October 5, 2021 19:12
@marinhero marinhero merged commit 9d2ab0a into master Oct 5, 2021
@marinhero marinhero deleted the marin/marketo-associateLead-deprecation branch October 5, 2021 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants