Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • lori ryan 239 posts 573 karma points
    Jan 04, 2018 @ 11:40
    lori ryan
    0

    personalisation Groups Country Matching

    Just getting started with personalisation Groups - Ive gotten the time based personalisation to work i.e.

    @Umbraco.MatchesGroup("Weekday Morning Visitors");

    Just having a bit of difficulty getting the country matching one to work. I ve created a personalisation called "country match"enter image description here

    Ive downloaded the GeoLite2-Country.mmdb into the app data folder.

    And added the following in appSettings in my web.config :

    <add key="personalisationGroups.geoLocationCountryDatabasePath" value="/App_Data/GeoLite2-Country.mmdb"/>
    

    However @Umbraco.MatchesGroup("Country Match"); always returns false.

    The personalisation I am looking to do is fairly basic i.e. if in Ireland show this pic if in Uk show this pic etc.

    Any help or pointers would be fantastic.

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jan 04, 2018 @ 12:49
    Andy Butland
    100

    Could be you are running locally, in which case your local IP for requests will be 127.0.0.1, and so not located in a particular country. If that's the issue, try setting the config value testFixedIp documented here.

    That should allow you test locally for various known IPs of different countries.

    When you deploy to a server it should pick up the IP of the client's request and work as you'd expect.

    Andy

  • lori ryan 239 posts 573 karma points
    Jan 04, 2018 @ 13:35
    lori ryan
    0

    I try now and let you know. Thank you for coming back so quickly.

  • lori ryan 239 posts 573 karma points
    Jan 04, 2018 @ 14:28
    lori ryan
    0

    Thanks so much :-) really appreciate the quick response time.

  • keilo 568 posts 1023 karma points
    Jan 04, 2018 @ 13:01
    keilo
    0

    Is there any support for CloudFlare or one has to do custom handling of the real visitor IP in case of CloudFlare?

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jan 04, 2018 @ 13:10
    Andy Butland
    1

    Not specifically tested with Cloudflare no but as you can see here, am checking a number of header values to determine the requesting IP.

    Bear in mind that CDN caching (by URL) likely won't play nicely with server-side personalisation (i.e. returning different content for the same URL).

    Andy

  • keilo 568 posts 1023 karma points
    Jan 04, 2018 @ 13:17
    keilo
    0

    Thanks for the prompt reply and pointer.

    If the header CF-Connecting-IP could be added that would be even better, as I see CloudFlare support for X-Forwarded-For is rather different, where it appends originating ip if the header was present. From Cloudflare help @ https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers-

    CF-Connecting-IP
    
    To provide the client (visitor) IP address for every request to the origin, Cloudflare adds the CF-Connecting-IP header.
    
    "CF-Connecting-IP: A.B.C.D"
    
    Where A.B.C.D is the client's IP address, also known as the original visitor IP address.
    
    X-Forwarded-For
    
    X-Forwarded-For is a well-established HTTP header used by proxies, including Cloudflare, to pass along other IP addresses in the request. This is often the same as CF-Connecting-IP, but there may be multiple layers of proxies in a request path.
    
    Two possible outcomes.
    
    First, if there was no existing "X-Forwarded-For" header in the request sent to Cloudflare, then the header would have an identical value to the CF-Connecting-IP header, like this:
    
    "X-Forwarded-For: A.B.C.D"
    
    where A.B.C.D is the client's IP address, also known as the original visitor IP address.
    
    Second, if there was an "X-Forwarded-For" header present in the request sent to Cloudflare, Cloudflare appends the client's IP to its value, as the last in the list.
    
    "X-Forwarded-For: A.B.C.D[,X.X.X.X,Y.Y.Y.Y,]"
    
    where A.B.C.D is the client's IP address, also known as the original visitor IP address. X.X.X.X and Y.Y.Y.Y in this example are IP addresses along the route in the header value.
    
  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jan 04, 2018 @ 22:53
    Andy Butland
    1

    Would you like to try the latest version - 0.3.1? I've just released it and included this additional header.

    Andy

  • keilo 568 posts 1023 karma points
    Jan 05, 2018 @ 04:54
    keilo
    0

    That looks great, will try the latest version.......

    Thanks Andy!

Please Sign in or register to post replies

Write your reply to:

Draft