Hi there,
For this, we generated an API Key using API Key - ipdata
Next, go to Custom Codes > Custom JS (Body) and add the following:
<script> function json(url) { return fetch(url).then(res => res.json()); } let apiKey = '35b57d04281f02df752982fac4d9c05e4f56f37eaef50ccffd597fe7'; json(`https://api.ipdata.co?api-key=${apiKey}`).then(data => { document.querySelector(".city_name .paragraph-inner *").innerHTML = data.city; console.log(data.country_code); }); </script>
Finally, Select any paragraph element, go to Advanced, and add city_name
as a Class Name. The City name will be displayed on the preview instead of the dummy text.
PS: Other info can be extracted from the object data such as the country.
Let us know how it goes.