When a user signs up on Developer portal, I want to be able to store from which source they came to my site As we posted many ads in google, twitter, fb

Not applicable

I would like to add a lead source functionality to the dev portal form. We’re starting a new ad campaign to help drive registrations and we’d like to know where the new registrations are coming from the various ads we created.I would like to track the URL of the ad, aIso it possible to add a hidden field in the form, so that the users don’t see it but only we can? Can we create reports based on the hidden field?

Solved Solved
0 2 347
1 ACCEPTED SOLUTION

@saranya sekar ,

Yes, It's definitely possible. Just create a text field / select field in user registration form. You need to implement a custom module that capture lead from url & populates the field when user submits the form using Drupal Hooks.

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_FORM_ID_alter...

View solution in original post

2 REPLIES 2

@saranya sekar ,

Yes, It's definitely possible. Just create a text field / select field in user registration form. You need to implement a custom module that capture lead from url & populates the field when user submits the form using Drupal Hooks.

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_FORM_ID_alter...

@Anil Sagar

I tried creating a custom module and added the code below: But it doesn't seem to work, Please correct me if am doing some thing wrong:

https://dev-knurld.devportal.apigee.com/user/register?utm_source=Twitter&utm_medium=Ad&utm_campaign=...

This is the URL in twitter and when user clicks the link, it goes to our registration page and i have to fetch the value of utm_source= Twitter and display in "How did you hear about us ?" field on the registration page and save in the db, before submitting the form.

This is my code:

function user_reg_customization_form_alter(&$form, $form_state, $form_id)

{

if ($form_id == 'user_register_form')

{

$form['#submit'][] = 'user_register_form_alter';

}

}

/* function to populate how did you hear about us before submit */

function user_register_form_alter(&$form, $form_state, $form_id) {

// Modification for the form with the given form ID goes here. For example, if

// FORM_ID is "user_register_form" this code would run only on the user

// registration form.

// Autopopulate the How did you hear about us field

$form['field_how_did_you_hear_about_us_'] = array(

'#type' => 'textfield',

'#title' => t('How did you hear about us'),

'#value'=> $_GET[utm_source],

'#required' => FALSE,

);

return $form;

}