satellite/analytics: separate hubspot form for personal vs business
This change separates hubspot form submission for personal and business accounts, with new company name and storage needs fields. Issue: https://github.com/storj/storj-private/issues/220 Change-Id: Ieb0fb64f87614c7327dc5f894140fb8a54ededa0
This commit is contained in:
parent
bebfb91b66
commit
771d2269ab
@ -7,6 +7,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -26,6 +27,16 @@ var mon = monkit.Package()
|
|||||||
const (
|
const (
|
||||||
eventPrefix = "pe20293085"
|
eventPrefix = "pe20293085"
|
||||||
expiryBufferTime = 5 * time.Minute
|
expiryBufferTime = 5 * time.Minute
|
||||||
|
// string template for hubspot submission form. %s is a placeholder for the form(ID) being submitted.
|
||||||
|
hubspotFormTemplate = "https://api.hsforms.com/submissions/v3/integration/submit/20293085/%s"
|
||||||
|
// This form(ID) is the business account form.
|
||||||
|
professionalFormID = "cc693502-9d55-4204-ae61-406a19148cfe"
|
||||||
|
// This form(ID) is the personal account form.
|
||||||
|
basicFormID = "77cfa709-f533-44b8-bf3a-ed1278ca3202"
|
||||||
|
// The hubspot lifecycle stage of business accounts (Product Qualified Lead).
|
||||||
|
businessLifecycleStage = "66198674"
|
||||||
|
// The hubspot lifecycle stage of personal accounts.
|
||||||
|
personalLifecycleStage = "other"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HubSpotConfig is a configuration struct for Concurrent Sending of Events.
|
// HubSpotConfig is a configuration struct for Concurrent Sending of Events.
|
||||||
@ -128,18 +139,46 @@ func (q *HubSpotEvents) EnqueueCreateUser(fields TrackCreateUserFields) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formFields := []map[string]interface{}{
|
||||||
|
newField("email", fields.Email),
|
||||||
|
newField("firstname", firstName),
|
||||||
|
newField("lastname", lastName),
|
||||||
|
newField("origin_header", fields.OriginHeader),
|
||||||
|
newField("signup_referrer", fields.Referrer),
|
||||||
|
newField("account_created", "true"),
|
||||||
|
newField("have_sales_contact", strconv.FormatBool(fields.HaveSalesContact)),
|
||||||
|
newField("signup_partner", fields.UserAgent),
|
||||||
|
}
|
||||||
|
|
||||||
|
properties := map[string]interface{}{
|
||||||
|
"userid": fields.ID.String(),
|
||||||
|
"email": fields.Email,
|
||||||
|
"name": fields.FullName,
|
||||||
|
"satellite_selected": q.satelliteName,
|
||||||
|
"account_type": string(fields.Type),
|
||||||
|
"company_size": fields.EmployeeCount,
|
||||||
|
"company_name": fields.CompanyName,
|
||||||
|
"job_title": fields.JobTitle,
|
||||||
|
}
|
||||||
|
|
||||||
|
var formURL string
|
||||||
|
|
||||||
|
if fields.Type == Professional {
|
||||||
|
formFields = append(formFields, newField("lifecyclestage", businessLifecycleStage))
|
||||||
|
formFields = append(formFields, newField("company", fields.CompanyName))
|
||||||
|
formFields = append(formFields, newField("storage_needs", fields.StorageNeeds))
|
||||||
|
|
||||||
|
properties["storage_needs"] = fields.StorageNeeds
|
||||||
|
|
||||||
|
formURL = fmt.Sprintf(hubspotFormTemplate, professionalFormID)
|
||||||
|
} else {
|
||||||
|
formFields = append(formFields, newField("lifecyclestage", personalLifecycleStage))
|
||||||
|
|
||||||
|
formURL = fmt.Sprintf(hubspotFormTemplate, basicFormID)
|
||||||
|
}
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"fields": []map[string]interface{}{
|
"fields": formFields,
|
||||||
newField("email", fields.Email),
|
|
||||||
newField("firstname", firstName),
|
|
||||||
newField("lastname", lastName),
|
|
||||||
newField("lifecyclestage", "other"),
|
|
||||||
newField("origin_header", fields.OriginHeader),
|
|
||||||
newField("signup_referrer", fields.Referrer),
|
|
||||||
newField("account_created", "true"),
|
|
||||||
newField("have_sales_contact", strconv.FormatBool(fields.HaveSalesContact)),
|
|
||||||
newField("signup_partner", fields.UserAgent),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if fields.HubspotUTK != "" {
|
if fields.HubspotUTK != "" {
|
||||||
@ -149,25 +188,16 @@ func (q *HubSpotEvents) EnqueueCreateUser(fields TrackCreateUserFields) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createUser := HubSpotEvent{
|
createUser := HubSpotEvent{
|
||||||
Endpoint: "https://api.hsforms.com/submissions/v3/integration/submit/20293085/77cfa709-f533-44b8-bf3a-ed1278ca3202",
|
Endpoint: formURL,
|
||||||
Data: data,
|
Data: data,
|
||||||
}
|
}
|
||||||
|
|
||||||
sendUserEvent := HubSpotEvent{
|
sendUserEvent := HubSpotEvent{
|
||||||
Endpoint: "https://api.hubapi.com/events/v3/send",
|
Endpoint: "https://api.hubapi.com/events/v3/send",
|
||||||
Data: map[string]interface{}{
|
Data: map[string]interface{}{
|
||||||
"email": fields.Email,
|
"email": fields.Email,
|
||||||
"eventName": eventPrefix + "_" + strings.ToLower(q.satelliteName) + "_" + "account_created",
|
"eventName": eventPrefix + "_" + strings.ToLower(q.satelliteName) + "_" + "account_created",
|
||||||
"properties": map[string]interface{}{
|
"properties": properties,
|
||||||
"userid": fields.ID.String(),
|
|
||||||
"email": fields.Email,
|
|
||||||
"name": fields.FullName,
|
|
||||||
"satellite_selected": q.satelliteName,
|
|
||||||
"account_type": string(fields.Type),
|
|
||||||
"company_size": fields.EmployeeCount,
|
|
||||||
"company_name": fields.CompanyName,
|
|
||||||
"job_title": fields.JobTitle,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
@ -176,6 +176,7 @@ type TrackCreateUserFields struct {
|
|||||||
Type UserType
|
Type UserType
|
||||||
EmployeeCount string
|
EmployeeCount string
|
||||||
CompanyName string
|
CompanyName string
|
||||||
|
StorageNeeds string
|
||||||
JobTitle string
|
JobTitle string
|
||||||
HaveSalesContact bool
|
HaveSalesContact bool
|
||||||
OriginHeader string
|
OriginHeader string
|
||||||
@ -244,6 +245,7 @@ func (service *Service) TrackCreateUser(fields TrackCreateUserFields) {
|
|||||||
props.Set("company_size", fields.EmployeeCount)
|
props.Set("company_size", fields.EmployeeCount)
|
||||||
props.Set("company_name", fields.CompanyName)
|
props.Set("company_name", fields.CompanyName)
|
||||||
props.Set("job_title", fields.JobTitle)
|
props.Set("job_title", fields.JobTitle)
|
||||||
|
props.Set("storage_needs", fields.StorageNeeds)
|
||||||
}
|
}
|
||||||
|
|
||||||
service.enqueueMessage(segment.Track{
|
service.enqueueMessage(segment.Track{
|
||||||
|
@ -203,6 +203,7 @@ func (a *Auth) Register(w http.ResponseWriter, r *http.Request) {
|
|||||||
IsProfessional bool `json:"isProfessional"`
|
IsProfessional bool `json:"isProfessional"`
|
||||||
Position string `json:"position"`
|
Position string `json:"position"`
|
||||||
CompanyName string `json:"companyName"`
|
CompanyName string `json:"companyName"`
|
||||||
|
StorageNeeds string `json:"storageNeeds"`
|
||||||
EmployeeCount string `json:"employeeCount"`
|
EmployeeCount string `json:"employeeCount"`
|
||||||
HaveSalesContact bool `json:"haveSalesContact"`
|
HaveSalesContact bool `json:"haveSalesContact"`
|
||||||
CaptchaResponse string `json:"captchaResponse"`
|
CaptchaResponse string `json:"captchaResponse"`
|
||||||
@ -336,6 +337,7 @@ func (a *Auth) Register(w http.ResponseWriter, r *http.Request) {
|
|||||||
trackCreateUserFields.Type = analytics.Professional
|
trackCreateUserFields.Type = analytics.Professional
|
||||||
trackCreateUserFields.EmployeeCount = user.EmployeeCount
|
trackCreateUserFields.EmployeeCount = user.EmployeeCount
|
||||||
trackCreateUserFields.CompanyName = user.CompanyName
|
trackCreateUserFields.CompanyName = user.CompanyName
|
||||||
|
trackCreateUserFields.StorageNeeds = registerData.StorageNeeds
|
||||||
trackCreateUserFields.JobTitle = user.Position
|
trackCreateUserFields.JobTitle = user.Position
|
||||||
trackCreateUserFields.HaveSalesContact = user.HaveSalesContact
|
trackCreateUserFields.HaveSalesContact = user.HaveSalesContact
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user