Google Analytics provide a feature that can analyze "Age" & "Gender" of visitors. But my customer want to track these data by submiting a form after checkout successfully.
That form looks as follow:
<form id="form-checkout" class="form-success" method="post" action="">
<ol class="fs-fields">
<li class="gender">
<label><?php echo $this->__('Gender') ?></label>
<div class="fs-radio-group fs-radio-custom clearfix fs-anim-lower">
<span><input type="radio" name="gender" value="Male" /><label><?php echo $this->__('Male')?></label></span>
<span><input type="radio" name="gender" value="Female" /><label><?php echo $this->__('Female')?></label></span>
</div>
</li>
<li class="ages">
<label><?php echo $this->__('Ages') ?></label>
<select name="ages">
<option value="< 20"><?php echo $this->__('< 20') ?></option>
<option value="20-35"><?php echo $this->__('20-35') ?></option>
<option value="35-50"><?php echo $this->__('35-50') ?></option>
<option value="> 50"><?php echo $this->__('> 50') ?></option>
</select>
</li>
</ol>
<div class="button-box">
<button class="fs-submit fs-show" type="button" title="<?php echo $this->__('submit') ?>" onclick="sendDataToUa();"><span><?php echo $this->__("Back to Home")?></span></button>
<button class="fs-submit fs-show" type="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><?php echo $this->__('Continue Shopping') ?></span></button>
</div>
</form>
Js script:
<script type="text/javascript">
function sendDataToUa(){
var gender = jQuery('input[name=gender]:checked', '#form-checkout').val();
var ages = jQuery('#form-checkout option:selected').val();
ga('set', 'dimension1', gender);
ga('set', 'dimension2', ages);
ga('send', 'pageview', {
'dimension1': gender,
'dimension2': ages,
});
}
</script>
UPDATE: I'm waiting for report data on google analytics.