Get answers quicker by searching

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

[Mod] Update User Country Code by Campaign Opens - Sendy v3.0.9.1
  • Vote Up0Vote Down gavn8rgavn8r
    Posts: 7Sendy user

    I love how campaign reports in Sendy show the countries that users are in when they open an email. I wanted to have the country code inside the subscribers table updated each time a subscriber opens an email so I can have updated segments, which I've created by country.

    I'm an amateur coder, and created a PHP file to accomplish this goal.

    Download it here:

    Install it by uploading it into your Sendy root directory.

    Set a cron job to call the php file:

    Command: php /your/directory/update-country.php > /dev/null 2>&1

    Time Interval: */15 * * * *

    Use at your own risk. It's working perfectly for me.

  • Vote Up0Vote Down IanIan
    Posts: 26Sendy user

    Thanks for your contribution. I'm curious and have two questions. Could you kindly advise?

    1. Is this feature created mainly to use on subscribers who travel a lot and to know which countries they are traveling to? Are there other use cases?

    2. What's your consideration of using cron job to do the task every 15 minutes rather than using an embedded-in-email image pixel (which would update each subscriber's country only when he/she opens an email)?

  • The image pixel idea sounds more efficient IMO

  • Vote Up0Vote Down colcolcolcol
    Posts: 21Sendy user

    I love how users can create their own extra code to enhance Sendy -- well done @gavn8r.

    Would the image pixel idea involve amending the existing Sendy code? Not ideal for amateur/non-coders.

  • Vote Up0Vote Down IanIan
    Posts: 26Sendy user

    @colcol Regarding the creation of the image pixel, I would say it only needs a new PHP page and probably also a new line in the .htaccess file. Existing Sendy code wouldn't need to be amended.

  • Vote Up0Vote Down gavn8rgavn8r
    Posts: 7Sendy user

    I like the idea of the image pixel. That's beyond my capability, I think. I'd love it if someone more talented could pick up the ball and run with it.

    The reason I did it in the first place was simply to be able to send different messages to people in different geographies. My client has offers that are territory-specific. The reason for the 15 minute interval was completely arbitrary. It could be set up to update less frequently.

  • Vote Up0Vote Down IanIan
    Posts: 26Sendy user

    @gavn8r Thanks. I understand that some products are country-specific. I'm just under an impression that the majority of people hardly keep relocating between countries.

  • Vote Up0Vote Down IanIan
    Posts: 26Sendy user

    Besides, lots of people use Gmail. And Google caches images (including Sendy's tracking image pixel) on their servers. So sometimes after you test opening an email sent by Sendy, you check the statistics and see the email was opened in PH (Philippine). That's because that Sendy's tracking image pixel was cached on Google's Philippine server. Therefore country detecting done by the tracking image pixel isn't always reliable.

  • Vote Up0Vote Down gavn8rgavn8r
    Posts: 7Sendy user

    That's something I didn't know. Thanks for that clarification, Ian.

  • Vote Up0Vote Down IanIan
    Posts: 26Sendy user

    You're welcome, gavn8r.

  • Vote Up0Vote Down petempetem
    Posts: 2Sendy user

    I've just added this and I have to say it has a superb use case for me. Our clients are predominantly in the Middle East, where people frequently travel and can be gone for months at a time before returning. This is a game-changer for one of my clients.

    However, setting the cron to once per week is plenty for now.

  • This is interesting, thanks for the contribution! I've just added automated capture of country on the signup form, so brand new users have their country stamped into their records. Older ones don't, though; and this seems a nice way to quickly add this data.

    Question: if User A has their subscriber country set to "Australia" but opens an email from a "Canada" IP address, does it say "Canada" or "Australia" in the campaign dashboard for that email?

  • Vote Up0Vote Down beekingbeeking
    Posts: 17Sendy user

    Nice mod, thanks! Its very resource intensive with huge lists. I changed the cron to run daily instead of every 15 minutes.

  • Vote Up0Vote Down DigitalDanDigitalDan
    Posts: 9Sendy user

    Does this work with Sendy 4?

  • Vote Up0Vote Down matthawk60matthawk60
    Posts: 3Sendy user

    Does anyone have a copy of this code? I get a 404 for that google doc.