# Update \`lifecycle\` property within Events API

**URL:** <https://community.hubspot.com/t/update-lifecycle-property-within-events-api/11625>\
**Category:** APIs & Integrations\
**Tags:** events\
**Created:** [May 1, 2018, 7:34pm UTC](https://community.hubspot.com/t/update-lifecycle-property-within-events-api/11625 "2018-05-01T19:34:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [May 1, 2018, 7:34pm UTC](https://community.hubspot.com/t/update-lifecycle-property-within-events-api/11625/1 "2018-05-01T19:34:54Z")

</div>

Hey there Hubspotters,

I’m trying to help our Sales team get more value out of the Hubspot Platform, notably the Marketing Contacts. Currently, we have a register modal on our website to `sign up` a user in the Contacts tab, fired from the Events API. This works.

Once a User registers, our platform allows the opportunity to create and host their own events — a user can fill out a form with their event details and we will produce a public Event Details Page that the host can share. People can visit the Event Details Page and purchase tickets to said event. We have a separate event that tracks when the host actually posts their event to the public, called `Published Event`. This also works.

I’m trying to understand how to update a user’s `lifecycle` property — the logic to transition them from a Subscriber to Customer should consist of the user publishing an event. I presume I’ll need to execute the update code in the form where events are published…like something within the `Published Event` event that checks if this is a user’s first event, and if so update their `lifecycle` property to `customer`.

Is this possible? Any help?

**\_register\_modal.html.haml**

```auto
document.querySelector("#new_user").onsubmit = ->
 fullName = document.querySelector('#full-name').value
 email = document.querySelector('#email').value
 firstName = fullName.split(" ")[0]
 _hsq = window._hsq = window._hsq || []

if fullName.indexOf(" ") != -1
 lastName = fullName.substring(fullName.indexOf(" "))
 else
 lastName = ""

_hsq.push(["identify",{
 email: email,
 firstName: firstName,
 lastName: lastName
}])

_hsq.push(["trackEvent", { id: 'sign up' }])

```

**Listing-create-edit.coffee**

```auto
_publishListing: ->
 @get('listing').save().then (listing) =>
 @set('listing.user_id', undefined)
 if "@@ENV.environment" == 'production'
 fbq 'trackCustom', 'CreatedListing', created_listing: 'createdListing'
 listing.submit().then () =>
 if "@@ENV.environment" != 'test'
 location.href = "/events/#{@get('listing.slug_param')}/manage"
 @get('flash').success @get('listingSuccessfullyCreated')
 @gaSuccess @get 'listing'
 analytics.track "Published Event", { Location: "create_form" }
 _hsq.push(["trackEvent", {
 id: "Published Event"
 }])
 , =>
 @get('flash').error 'Could not submit listing'
 , =>
 @get('flash').error @get('problemCreatingListing')

```

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [May 2, 2018, 6:47pm UTC](https://community.hubspot.com/t/update-lifecycle-property-within-events-api/11625/2 "2018-05-02T18:47:07Z")

</div>

Hi [@tbcooney](https://community.hubspot.com/u/tbcooney),

You can’t directly update contact properties using the Events Javascript API, but there are a number of ways to update a contact’s Lifecycle Stage when the `Published Event` event occurs. The `identify` method is the only Tracking Code API method that can update contact properties; you might consider making another `identify` call when a user publishes a page, including the Lifecycle Stage property like this:

```auto
_hsq.push(["identify",{
 email: email,
 lifecyclestage: "customer"
}])

```

The simplest method would actually be to create a simple workflow that enrolls contacts when they complete the `Published Event` event and updates their Lifecycle Stage to ‘Customer’. This would eliminate the need to change anything about your code.

Let me know if you have any other questions on this!

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [May 8, 2018, 3:03pm UTC](https://community.hubspot.com/t/update-lifecycle-property-within-events-api/11625/3 "2018-05-08T15:03:11Z")

</div>

Thanks for explaining both approaches in your response Derek, really helpful  
 ![+1.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/4/46308e1e5249a15b31f82cd4a68964496666bccb.png)

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [May 18, 2018, 6:49pm UTC](https://community.hubspot.com/t/update-lifecycle-property-within-events-api/11625/4 "2018-05-18T18:49:28Z")

</div>

Final implementation that I got working in coffeescript:

```auto
 email = @get('currentUser.email')

 _hsq.push(["identify",{
 email: email,
 lifecyclestage: "customer"
 }])

```

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [May 17, 2018, 9:17pm UTC](https://community.hubspot.com/t/update-lifecycle-property-within-events-api/11625/5 "2018-05-17T21:17:15Z")

</div>

Hey @Derek_Gervais…I need a hand now that I’m trying to implement the `identify` call when a user publishes a page.

I’ve placed the `identify` call before the `trackEvent` call; the `trackEvent` call shows up in the activity log but the Contact doesn’t change to a “customer”. Am I missing a comma to chain these two calls together or anything trivial?

```auto
_publishListing: ->
 @get('listing').save().then (listing) =>
 @set('listing.user_id', undefined)
 if "@@ENV.environment" == 'production'
 fbq 'trackCustom', 'CreatedListing', created_listing: 'createdListing'
 listing.submit().then () =>
 if "@@ENV.environment" != 'test'
 location.href = "/events/#{@get('listing.slug_param')}/manage"
 @get('flash').success @get('listingSuccessfullyCreated')
 @gaSuccess @get 'listing'
 analytics.track "Published Event", { Location: "create_form" }
 _hsq.push(["identify",{
 email: email,
 lifecyclestage: "customer"
 }])
 _hsq.push(["trackEvent", {
 id: "Published Event"
 }])
 , =>
 @get('flash').error 'Could not submit listing'
 , =>
 @get('flash').error @get('problemCreatingListing')

```

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [May 18, 2018, 5:36pm UTC](https://community.hubspot.com/t/update-lifecycle-property-within-events-api/11625/6 "2018-05-18T17:36:35Z")

</div>

Update - I replaced `email: email` with a hardcoded email of a Contact and it update the Lifecycle Stage when the event fired. I guess my issue is grabbing the users email; in prior `identify` calls, I grab the email from the signup form. Here, the user is already logged in, so I need to capture and pass the `user.email`
