Copied to clipboard

Flag this post as spam?

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


  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 20, 2022 @ 12:08
    Dave Woestenborghs
    0

    Getting country for Visitor

    Hi,

    We are implementing a custom IRawPageviewLocationExtractor so we have location data in the analytics as documented here : https://documentation.umarketingsuite.com/analytics/extending-analytics/implement-an-ip-to-location-provider/

    How can I get the country for the current visitor so I can show different content based on that information ?

    Dave

  • Daniël Knippers 153 posts 1117 karma points MVP 2x c-trib
    Jun 22, 2022 @ 10:18
    Daniël Knippers
    0

    Hi Dave,

    Unfortunately there is no API at the moment to retrieve the Location of a Visitor. Locations obtained from the IRawPageviewLocationExtractor are persisted alongside the Pageview they belong to and are currently only used to render a chart in Analytics in the backoffice (Analytics > Location).

    If you want to show different content to a visitor based on their location you would actually have to implement a custom segment parameter, i.e. "Location". This custom segment parameter would then show up in the segment builder: enter image description here

    You can then create segments based on this parameter, e.g. one for "country = Netherlands" and one for "country = Belgium" or so and use them in personalizations to customize content.

    Of course a "Location" segment parameter is a good candidate to be part of the built-in UMS parameters but unfortunately we have not made this one yet. I imagine when we do we would actually require an implementation of IRawPageviewLocationExtractor and use those locations in this parameter, but if you want to implement this today you will have to create a custom one and then you could just perform the location lookup in the parameter only.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 22, 2022 @ 10:40
    Dave Woestenborghs
    1

    Hi Daniel,

    I found a away to get visitors location. I am using the GetState method on the IAnalyticsStateProvider

    The model returned from that allows me to drill down to IP information and the location is part of that.

    Dave

  • Daniël Knippers 153 posts 1117 karma points MVP 2x c-trib
    Jun 22, 2022 @ 11:30
    Daniël Knippers
    0

    Excellent! Yes that is indeed the ILocation associated with the current IPageview so you can use that too if that is enough. If you want to allow editors to customize content in splitview as part of a personalization for example you will need a segment though.

Please Sign in or register to post replies

Write your reply to:

Draft