Skip to content

[Mod] Update User Country Code by Campaign Opens - Sendy v3.0.9.1

edited June 2019 in Contributions

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: https://drive.google.com/open?id=1h2BgHJLNQdwJtl-5Ax0qzYk8DxAMab6B

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.

Comments

  • IanIan
    edited June 2018

    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

  • 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.

  • IanIan
    edited June 2018

    @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.

  • 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.

  • IanIan
    edited June 2018

    @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.

  • IanIan
    edited June 2018

    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.

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

  • You're welcome, gavn8r.

  • 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?

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

  • Does this work with Sendy 4?

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

  • Does anyone have a copy of this? I'd love to implement this in v5

  • Well, I made a bit of a rookie error, and assumed that the subscriber's IP address would automatically be stored with signups through the API, then (hopefully) looked up using a geoip service. I just couldn't work out why my segments by country weren't yielding any members, when it was clear that Sendy is looking up the recipients country with their IP address to breakdown the opens.

    Since I'm using Joomla and there's only a really basic implementation of the API on Joomla I'm writing my own. Thus far, I've got maxmind's GeoIP2 library loaded in a Joomla system plugin and am successfully passing both IP address and now, the ISO country code being stored with my signups.

    I guess in the future, I will add an api method to my plugin that can batch process these from Sendy, but for now, storing it at signup is good enough for me.

Sign In or Register to comment.