You have to add the control:
<cms:BizForm ID="viewBiz" runat="server" IsLiveSite="true" />
Then you can set which form to use in SetUpControl() which is called in OnContentLoaded():
viewBiz.FormName = FormName;
viewBiz.SiteName = SiteContext.CurrentSiteName;
viewBiz.UseColonBehindLabel = true;
viewBiz.AlternativeFormFullName = AlternativeFormName;
viewBiz.ValidationErrorMessage = "There was an error";
// Set the live site context
if (viewBiz != null)
{
viewBiz.ControlContext.ContextName = CMS.ExtendedControls.ControlContext.LIVE_SITE;
}
formname being a property I set on the webpart.
Then in OnLoad you can add:
viewBiz.OnAfterSave += viewBiz_OnAfterSave;
private void viewBiz_OnAfterSave(object sender, EventArgs e)
{
if (TrackConversionName != String.Empty)
{
string siteName = SiteContext.CurrentSiteName;
if (AnalyticsHelper.AnalyticsEnabled(siteName) && !AnalyticsHelper.IsIPExcluded(siteName, RequestContext.UserHostAddress))
{
HitLogProvider.LogConversions(SiteContext.CurrentSiteName, LocalizationContext.PreferredCultureCode, TrackConversionName, 0, ConversionValue);
}
}
}