Recent searches


No recent searches

Getting User's Name and E-mail variables for Widget

Answered


Posted Jun 14, 2016

Hello,

I'm working on theming and adding elements to our Zendesk, but having some issues with a few things, and while there is some extensive documentation, I feel like sometimes the API documentation and tutorials fall a tad short for actual usage. Such as it telling how to use the zE.identify function.

In the example used, however this just shows you how to put in static values.
I can't for the life of me figure out how to actually populate these values with the actual name and e-mail of the logged in user, even after searching through and reading many of the posts here.
I keep seeing "see the API documentation" however it only shows inputing static values and not pulling in variables or anything.

I'm hoping someone has figured out how to do this or possibly has an example of how to pull these values!
Thank you! 

 

The example in documentation:

<script>
  zE(function() {
    zE.identify({
      name: 'John Citizen',
      email: 'john@example.com',
      organization: 'VIP'
    });
  });
</script>



0

7

7 comments

Official

image avatar

Nicole Saunders

Zendesk Community Manager

Hey Jeremy - 

I've posted the solution Dwight shared with Eric below. This isn't my area of expertise, so let us know if that answers your question or if you need more info: 

 

__

Here's an article that walks through how to auto-populate that contact form: https://support.zendesk.com/hc/en-us/articles/204172316-Auto-fill-the-Web-Widget-Contact-Form

The basic gist is that you can insert the following code immediately after the web-widget code within your header page:

Within my own test account, it looks like this:
​​


Please let me know if this helps with what you're trying to do!

0


Hey Eric,

The way you can get the current user attributes (for use in zE.identify) is by using the users./me.json endpoint. 

More information on this can be found in this link:

https://developer.zendesk.com/rest_api/docs/core/users#show-the-currently-authenticated-user

Hope that helps!

0


Hello Jonathan,

Thank you for the response, but are there better examples of actually utilizing something like this? 

When actually editing the pages and trying to use this, I'm not sure how to actually use the get statement or tell the ze.Identify to pull the name and email from it. 

Thank you again.

0


image avatar

Dwight Bussman

Zendesk Customer Care

Hi Eric,

I'm going to reach out to you within a ticket so that we're not going back and forth within here. I'd be happy to add our eventual solution back to this page once we've worked something out.

I'll see you on that channel shortly! Thanks.

0


Dwight/Eric, or anyone else who may look at this - 

Any follow up on this from 3 years ago? Last comment was a solution coming back to this post, but no solution provided.

I too am looking at how to populate the GET data for a user into a specific section of my code/scripts to gain usage data in our backend system. I can do some stuff with RegEx, but want to shy away from that as much as I can since it's not as reliable as a coded solution that pulls the correct data EVERY time a user is authenticated.

I want to use this outside of the script.js file in our Copenhagen theme, and the values I am most interested in getting/populating are: UserID, Name, Email, Organization_ID

 

Anyone else have thoughts on this too?

0


Thanks Nicole, this does help with what I am trying to do. I appreciate the quick turnaround and follow up even through I posted on a several-years old thread.

0


image avatar

Nicole Saunders

Zendesk Community Manager

Great! I'm so glad to hear that it's useful. You're quite welcome. :)

0


Post is closed for comments.

Didn't find what you're looking for?

New post