Jump to:

1976 Posts in 1306 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » Marketo Form Integration

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 989 Views
  • VictorH
    Avatar
    Community Member
    29 Posts

    Marketo Form Integration Link to this post

    I created the form below which simply sends out a couple of emails. I need to update it so that it submits to Marketo. Does anyone have any experience? I've attached the PHP code (renamed marketo.txt so that I would be able to upload it) supplied by Market but I'm now sure where to start. Any help would be appreciated.

    Here's the code of the current form.

    public function SignUpForm() {
          // Sign Up Form Fields
          $fields = new FieldSet(
             new TextField('firstname','First Name*'),
             new TextField('lastname','Last Name*'),         
             new TextField('creditunion', 'Credit Union*', $this->getSearchQuery()),
             new EmailField('email','E-mail address*'),
             new TextField('city','City*'),
             new DropdownField('state', 'State', array(
                '' => 'State',
                'AL' => 'Alabama',
                'AK' => 'Alaska',
                'AZ' => 'Arizona'
        )),
        new HiddenField ('cn', 'CN')
          );
          
          // On Submit
          $actions = new FieldSet(
             new FormAction('doSignUp', 'Submit')
          );
          
          // Fields to validate
          $validator = new RequiredFields('firstname', 'lastname', 'creditunion', 'email');

          return new Form($this, 'SignUpForm', $fields, $actions, $validator);
       }

       function doSignUp($data, $form) {      
          // Send Email to Admin
          
          // Send Email to User
          
          Director::redirect(Director::baseURL(). $this->URLSegment . "/?signupsuccess=1");
       }

    Attached Files
  • NicoHaase
    Avatar
    Community Member
    6 Posts

    Re: Marketo Form Integration Link to this post

    It shouldn't be that difficult: at the point where you send out the mail (in doSignup), you integrate the call to Marketo (whatever that service does). Copy the code from the branch starting with if ($isPostback), modify the parameters you pass (eg $_REQUEST['email'] could become $data['email'], as all fields contained in the form are represented in $data), and you should be done

  • VictorH
    Avatar
    Community Member
    29 Posts

    Re: Marketo Form Integration Link to this post

    Thanks for the reply.

    I'm getting ready to do what you recommend but before I do wanted to ask about the code below which appears after ($isPostback). I noticed that it contains references to a class (mktSampleMktowsClient) in the rest of the code. Where and when do I integrate that class?

    # USER_ID and SECRET_KEY need to be created through Marketo web interface and pasted on lines 999 and 1000 of this file
       $accessKey = mktSampleMktowsClient::MKTOWS_USER_ID;
       $secretKey = mktSampleMktowsClient::MKTOWS_SECRET_KEY;

       // !!! SET END POINT TO YOUR CUSTOMER SPECIFIC URL, CAN BE FOUND IN MARKETO ADMIN INTERFACE !!!
       $soapEndPoint = 'https://na-n.marketo.com/soap/mktows/1_7';

       # a mktSampleMktowsClient object is created to make all the web service calls
       $client = new mktSampleMktowsClient($accessKey, $secretKey, $soapEndPoint);

  • NicoHaase
    Avatar
    Community Member
    6 Posts

    Re: Marketo Form Integration Link to this post

    Just create a new file for that class, besides the file in which your form occurs, and run /dev/build.

    989 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.