<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Update `lifecycle` property within Events API in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227308#M6204</link>
    <description>&lt;P&gt;Hey &lt;SPAN class="mention"&gt;@Derek_Gervais...I&lt;/SPAN&gt; need a hand now that I'm trying to implement the &lt;CODE&gt;identify&lt;/CODE&gt; call when a user publishes a page.&lt;/P&gt;
&lt;P&gt;I've placed the &lt;CODE&gt;identify&lt;/CODE&gt; call before the &lt;CODE&gt;trackEvent&lt;/CODE&gt; call; the &lt;CODE&gt;trackEvent&lt;/CODE&gt; 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?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;_publishListing: -&amp;gt;
    @get('listing').save().then (listing) =&amp;gt;
      @set('listing.user_id', undefined)
      if "@@ENV.environment" == 'production'
        fbq 'trackCustom', 'CreatedListing', created_listing: 'createdListing'
      listing.submit().then () =&amp;gt;
        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"
        }])
      , =&amp;gt;
        @get('flash').error 'Could not submit listing'
    , =&amp;gt;
      @get('flash').error @get('problemCreatingListing')&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 17 May 2018 21:17:15 GMT</pubDate>
    <dc:creator />
    <dc:date>2018-05-17T21:17:15Z</dc:date>
    <item>
      <title>Update `lifecycle` property within Events API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227305#M6201</link>
      <description>&lt;P&gt;Hey there Hubspotters,&lt;/P&gt;
&lt;P&gt;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 &lt;CODE&gt;sign up&lt;/CODE&gt; a user in the Contacts tab, fired from the Events API. This works.&lt;/P&gt;
&lt;P&gt;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 &lt;CODE&gt;Published Event&lt;/CODE&gt;. This also works.&lt;/P&gt;
&lt;P&gt;I'm trying to understand how to update a user's &lt;CODE&gt;lifecycle&lt;/CODE&gt; 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 &lt;CODE&gt;Published Event&lt;/CODE&gt; event that checks if this is a user's first event, and if so update their  &lt;CODE&gt;lifecycle&lt;/CODE&gt; property to &lt;CODE&gt;customer&lt;/CODE&gt;.&lt;/P&gt;
&lt;P&gt;Is this possible? Any help?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;_register_modal.html.haml&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;document.querySelector("#new_user").onsubmit = -&amp;gt;
        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' }])
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Listing-create-edit.coffee&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;_publishListing: -&amp;gt;
    @get('listing').save().then (listing) =&amp;gt;
      @set('listing.user_id', undefined)
      if "@@ENV.environment" == 'production'
        fbq 'trackCustom', 'CreatedListing', created_listing: 'createdListing'
      listing.submit().then () =&amp;gt;
        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"
        }])
      , =&amp;gt;
        @get('flash').error 'Could not submit listing'
    , =&amp;gt;
      @get('flash').error @get('problemCreatingListing')&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 May 2018 19:34:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227305#M6201</guid>
      <dc:creator />
      <dc:date>2018-05-01T19:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Update `lifecycle` property within Events API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227306#M6202</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/tbcooney"&gt;@tbcooney&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;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 &lt;CODE&gt;Published Event&lt;/CODE&gt; event occurs. The &lt;CODE&gt;identify&lt;/CODE&gt; method is the only Tracking Code API method that can update contact properties; you might consider making another &lt;CODE&gt;identify&lt;/CODE&gt; call when a user publishes a page, including the Lifecycle Stage property like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="lang-auto"&gt;_hsq.push(["identify",{
   email: email,
  lifecyclestage: "customer"
}])
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The simplest method would actually be to create a simple workflow that enrolls contacts when they complete the &lt;CODE&gt;Published Event&lt;/CODE&gt; event and updates their Lifecycle Stage to 'Customer'. This would eliminate the need to change anything about your code.&lt;/P&gt;
&lt;P&gt;Let me know if you have any other questions on this!&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 18:47:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227306#M6202</guid>
      <dc:creator>Derek_Gervais</dc:creator>
      <dc:date>2018-05-02T18:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Update `lifecycle` property within Events API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227307#M6203</link>
      <description>&lt;P&gt;Thanks for explaining both approaches in your response Derek, really helpful &lt;IMG src="https://community.hubspot.com/legacyfs/online/emojis/twitter/+1.png?v=5" title=":+1:" class="emoji" alt=":+1:" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 15:03:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227307#M6203</guid>
      <dc:creator />
      <dc:date>2018-05-08T15:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Update `lifecycle` property within Events API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227308#M6204</link>
      <description>&lt;P&gt;Hey &lt;SPAN class="mention"&gt;@Derek_Gervais...I&lt;/SPAN&gt; need a hand now that I'm trying to implement the &lt;CODE&gt;identify&lt;/CODE&gt; call when a user publishes a page.&lt;/P&gt;
&lt;P&gt;I've placed the &lt;CODE&gt;identify&lt;/CODE&gt; call before the &lt;CODE&gt;trackEvent&lt;/CODE&gt; call; the &lt;CODE&gt;trackEvent&lt;/CODE&gt; 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?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;_publishListing: -&amp;gt;
    @get('listing').save().then (listing) =&amp;gt;
      @set('listing.user_id', undefined)
      if "@@ENV.environment" == 'production'
        fbq 'trackCustom', 'CreatedListing', created_listing: 'createdListing'
      listing.submit().then () =&amp;gt;
        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"
        }])
      , =&amp;gt;
        @get('flash').error 'Could not submit listing'
    , =&amp;gt;
      @get('flash').error @get('problemCreatingListing')&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 May 2018 21:17:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227308#M6204</guid>
      <dc:creator />
      <dc:date>2018-05-17T21:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: Update `lifecycle` property within Events API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227309#M6205</link>
      <description>&lt;P&gt;Update - I replaced &lt;CODE&gt;email: email&lt;/CODE&gt; 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 &lt;CODE&gt;identify&lt;/CODE&gt; calls, I grab the email from the signup form. Here, the user is already logged in, so I need to capture and pass the &lt;CODE&gt;user.email&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 17:36:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227309#M6205</guid>
      <dc:creator />
      <dc:date>2018-05-18T17:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Update `lifecycle` property within Events API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227310#M6206</link>
      <description>&lt;P&gt;Final implementation that I got working in coffeescript:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;        email = @get('currentUser.email')

        _hsq.push(["identify",{
          email: email,
          lifecyclestage: "customer"
        }])&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 May 2018 18:49:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Update-lifecycle-property-within-Events-API/m-p/227310#M6206</guid>
      <dc:creator />
      <dc:date>2018-05-18T18:49:28Z</dc:date>
    </item>
  </channel>
</rss>

