How can we work with Geo-IP in local instance?
We are using Sitecore 7.2 in our project. We have a requirement that based on country Geo-IP home page needs to be redirected. Please help me in achieving this functionality in local instance.
geo-location
add a comment |
We are using Sitecore 7.2 in our project. We have a requirement that based on country Geo-IP home page needs to be redirected. Please help me in achieving this functionality in local instance.
geo-location
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
Jan 22 at 12:23
add a comment |
We are using Sitecore 7.2 in our project. We have a requirement that based on country Geo-IP home page needs to be redirected. Please help me in achieving this functionality in local instance.
geo-location
We are using Sitecore 7.2 in our project. We have a requirement that based on country Geo-IP home page needs to be redirected. Please help me in achieving this functionality in local instance.
geo-location
geo-location
edited Jan 22 at 10:20


Peter Procházka
5,3401943
5,3401943
asked Jan 22 at 10:07
user4934user4934
61
61
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
Jan 22 at 12:23
add a comment |
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
Jan 22 at 12:23
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
Jan 22 at 12:23
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
Jan 22 at 12:23
add a comment |
3 Answers
3
active
oldest
votes
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
3
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
Jan 22 at 12:22
add a comment |
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
add a comment |
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "664"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f16156%2fhow-can-we-work-with-geo-ip-in-local-instance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
3
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
Jan 22 at 12:22
add a comment |
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
3
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
Jan 22 at 12:22
add a comment |
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
edited Jan 22 at 12:10
answered Jan 22 at 10:28


Peter ProcházkaPeter Procházka
5,3401943
5,3401943
3
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
Jan 22 at 12:22
add a comment |
3
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
Jan 22 at 12:22
3
3
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
Jan 22 at 12:22
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
Jan 22 at 12:22
add a comment |
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
add a comment |
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
add a comment |
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
edited Jan 22 at 12:30


Gatogordo
12k21760
12k21760
answered Jan 22 at 10:28


Andrei AkonnikauAndrei Akonnikau
415
415
add a comment |
add a comment |
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
add a comment |
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
add a comment |
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
answered Jan 22 at 12:00


Vincent LuiVincent Lui
1126
1126
add a comment |
add a comment |
Thanks for contributing an answer to Sitecore Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f16156%2fhow-can-we-work-with-geo-ip-in-local-instance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
Jan 22 at 12:23