Expand my Community achievements bar.

Join us for an upcoming in-person Adobe Target Skill Builders event ~~> We're hosting these live learning opportunities to equip you with the knowledge and skills to leverage Target successfully. Learn more to see if we'll be coming to a city near you!
SOLVED

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

Avatar

Level 1

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?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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...

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-pa...

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

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

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...

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-pa...

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