Geo-Personalization: Pass user's location to html-code | Community
Skip to main content
New Participant
July 26, 2020
Solved

Geo-Personalization: Pass user's location to html-code

  • July 26, 2020
  • 1 reply
  • 1050 views

Hello,

I want to personalize a website by the location of the visitor.

 

For example, instead of writing: "Find new cars", I want to write: "Find new cars in {city}! So can I use Adobe Target to automatically replace the {city} string in the HTML code with the actual location of the user? Can I use profile.geolocation.city for that?

 

Also, can I pass the user's location (profile.geolocation.city?) as input to a Javascript function that is part of my website?

 

Can this happen in real time, i.e. during the first page view of the first visit?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ryanr7

Hi @marwal1,

Yes, you can to each of your questions. Here's the help doc on using tokens in your content/modifications (including inside a script): https://docs.adobe.com/content/help/en/target/using/experiences/offers/passing-profile-attributes-to-the-html-offer.html

It shows the basic syntax for adding the dynamic data. Essentially, you insert like so: ${domain.attribute}

Here is a help doc that list out all the profiles and variables available in Target including the geolocation variables: https://docs.adobe.com/content/help/en/target/using/audiences/visitor-profiles/variables-profiles-parameters-methods.html

So in your specific example, you could update the text on your page to say: "Find new cars in ${profile.geolocation.city}". Worth noting that all the geolocation values from Target are lower case so you may want to use some CSS to change the case. You can also use the ${profile.geolocation.city} inside of a script too. So if I was modifying the HTML of an element I could insert a small script. For example:

<h2>Find new car's in <span class="titleCase">${profile.geolocation.city}</span></h2>
<script>
document.querySelector("h2").setAttribute("title", "Find cars in ${profile.geolocation.city}");
</script>

Target runs the geolocation look up on the first request of a session, so it will be available to use in the first page view of a first time visitors session.

Hope that helps.

-Ryan

1 reply

ryanr7Accepted solution
Employee
July 29, 2020

Hi @marwal1,

Yes, you can to each of your questions. Here's the help doc on using tokens in your content/modifications (including inside a script): https://docs.adobe.com/content/help/en/target/using/experiences/offers/passing-profile-attributes-to-the-html-offer.html

It shows the basic syntax for adding the dynamic data. Essentially, you insert like so: ${domain.attribute}

Here is a help doc that list out all the profiles and variables available in Target including the geolocation variables: https://docs.adobe.com/content/help/en/target/using/audiences/visitor-profiles/variables-profiles-parameters-methods.html

So in your specific example, you could update the text on your page to say: "Find new cars in ${profile.geolocation.city}". Worth noting that all the geolocation values from Target are lower case so you may want to use some CSS to change the case. You can also use the ${profile.geolocation.city} inside of a script too. So if I was modifying the HTML of an element I could insert a small script. For example:

<h2>Find new car's in <span class="titleCase">${profile.geolocation.city}</span></h2>
<script>
document.querySelector("h2").setAttribute("title", "Find cars in ${profile.geolocation.city}");
</script>

Target runs the geolocation look up on the first request of a session, so it will be available to use in the first page view of a first time visitors session.

Hope that helps.

-Ryan