Data Tag Implementation and Use Cases

How to implement and use data tags effectively with OneSignal.

Get Your Free AccountSchedule a Demo

Introduction

[00:04]

Karima: Awesome. Hi everyone. Thank you for joining. We're very excited about today's topic. So a few things before we get started: This is the webinar-style session, so if you have any questions, please make sure to share them either in the chat or the Q and A section in Zoom and we'll make sure to answer your questions. This webinar is going to be recorded, and then we will share the recording with you at the end of the session. We will get started right now. Please do share your questions in the chat again or the Q and A section. Perfect.

So today's topic is going to be about Tag Implementation and Use Cases. This is something that we got before a lot from our customers. So we're covering it today.

So we will just start. We will share a little bit of information about OneSignal, and then we'll go through an implementation overview. We'll share some use cases and best practices. This would take about 30 minutes. So the whole presentation is going to be 20 minutes, and then we'll allow 10 minutes for questions at the end.

I'm really excited about our host today. You have Jon Fishman. I'm sure some of you have interacted with him and talked to him on our chat box or through the support email. Hi Jon.

Jon: Hi everybody.

Karima: And you have myself, Karima Wagner. I am on the Customer Success team here at OneSignal. So today, I'll just be assisting Jon with questions and I'll go over some items.

So our co-founders actually started as developers themselves and they came into the challenge of not finding the right solution to engage their customers. And that's how they ended up building OneSignal. We're really excited because today, we're catering to all different sorts of industries and businesses. We're located in the Bay Area.

So let's get started with tags. So before talking about why use tags, just a little overview of what tags are. So they're events or actions that users take either on your website or app that you want to capture to understand what their behavior is and target them and engage them using that information. Usually, tags have a key and a value that you store. Good afternoon, Eddie.

So why use tags? The first thing is that, again, you can really target your users in a very personalized way, and the implementation itself is easy. The reason there's a little bit of an asterisk there is because it's easy to implement if you're a developer. So if you're not technical at all, it might not be easy. But if you are a developer, it's something that takes very minimal effort, and Jon will be covering that in a bit.

The other thing is, beyond sending regular notifications to everyone or sending notification space on users' activity on the site, you can get really personalized and increase both engagement and the satisfaction of your users. Again, as I mentioned, it's super hyper-personalized without you having to manually go and message this person. So, that's really a valuable thing to have. The last thing, we've done a lot of analytics. We've seen other marketing leaders also analyze how tags actually impact the engagement. And you can see an increase in both conversions and revenue by implementing tags.

So this is where I will pass it over to Jon. These are a few things here that he will be covering - what are the things to consider before implementing tags, what is the level of effort, because this is something that we get asked a lot. He will actually be walking you through a live implementation of tags. He will be covering how you can implement through other providers such as Google Tag Manager, Tealium, or other platforms. He will also cover best practices around implementing. Jon, I'll pass it over to you, and I'll stop sharing for now.

Data Tags

[04:54]

Jon: Sounds good. Thanks, Karima. I'll go ahead and share my screen. Alright. Hi, everybody. So I wanted to basically go over a few things about tags to just keep in mind before you start implementing them. One is that OneSignal already collects a certain amount of data, so you shouldn't really send us any tags for data that's already being collected. A common example is like the last time the user was active in the app, if the user is actually subscribed or not subscribed, the first time that they subscribed to your app or website, how many times they've been back to your app or website while they're subscribed.

We do track like the app version, so if that's also something that you have set up in your mobile app. We track what country they're in, which is based on IP address. So if they change IP address or you want to track county or state or province or some other area, you could use tags for that. But for the country itself, you probably don't need to. Location points are helpful if you are using websites and you want to track them. But if you're using mobile apps, you don't need to track location points. Language code, we actually automatically detect the language code from the device, so you don't need to track that.

Most data that we collect is not personally identifiable information. So if you wanted to track that, you can - things like the user's name or email or things like that. We do have an email record, but that's if you actually have an email sent to us, like you actually want to send email from OneSignal. But if you just want to associate an email address with a push record, you would do that with tags. Let’s take a look at how that works.

So the code is very similar if you have an app or a website. Just for the webinar, I'll go ahead and show you how to implement it on web. The first thing that we want to do is figure out what kind of data that we actually want to tag the user with. So, this is information, like, did they perform a certain event, or are there certain things within push notifications that we want to add? For example, do we want to add the user's name to a push notification? Or a common example is an abandoned cart. We want to add the cart item that they purchased to the push notification. You can use tags for that. Like Karima shared earlier, a tag is just a key and a value string or integer data that you can use to create segments or add that information into the push notification.

Now, you can't do a raise. So a common question that we get is people ask like, "Okay, well, I have 10 categories on my website. Can I have a category key, and then each category, if the user wants it, that'll be part of the value, like technology, finance, breaking news? So the answer is no. You can't send us array data because the value, all those different things will actually be part of what you need to do to create that segment. So the best option for that case is that, if I have 10 different categories or 100 different categories, you would want to tag the user with the category as the key.

So a common thing would be, I have a blog about, I had to do technology and I talk about Android. So if my tag key here is Android, then the value would just be 1. Or you can actually be really creative with the value and make this how many times they've actually viewed an Android article or how many times the last time they viewed an article with Android. So if I did a Unix timestamp, I can actually tag them with the Unix timestamp, and then I know the last time they visited an article about Android or an article about iOS or an article about anything. It's whatever your blog is like pets, dogs. Maybe I have a dog. I have an animal blog and one of the sections is dogs and I want to talk about dogs.

So the way that it works is, you just set the key in the value. The code is very simple. We're looking at the code. Like Karima mentioned earlier that it's easy for developers and it may be not as easy for non-developers. That is true. But at the same time, if you are familiar with code and if you wanted to try adding some code to your site, we actually provide in our documentation all the code examples that you would need. When you go to the OneSignal Documentation under the Setup & SDK/API reference - SDK Reference here, all of our methods that we provide for our SDKs are in here. So if you actually scroll down to tagging, it will give you a high-level overview of all the information. It will also give you the example code you need to add text.

[10:17]

So for example, on the web, the JavaScript SDK, this is the code you need. As you can see on my website here, I have that set up to tag the user and I am tagging them, do sendTag method. So I'm tagging them with the value I put in this inbox, an input field, and then the value is going to be what's in this input field. So as soon as I press this button, I'll tag the user with dogs equals to 1. So I click that. And now in the OneSignal dashboard, back in my player ID record, refresh the page, and voilà, dogs equals to 1. So that's cool.

But what if they don't like dogs anymore? What if they like cats now? Well, to remove a tag, you simply just send it to an empty value. So I can do the same sendTag method, but I set dogs equals to an empty string. I’ll make that request again. Now, the tag has actually been removed, so I can't segment by them anymore.

As you can see, this is just a really common example of adding items into a field. But a really common example is an abandoned cart. So let's just pretend this is my awesome sunglasses that I'm selling on my website, and this user decides like, "You know what, I'm going to add this item to the cart." So they click that button. And under the hood, what they did was they just clicked that button, which triggered this method I created called 'on add to cart button'. What it's doing is it's adding a UNIX timestamp. That's the current date and time represented in seconds. It's from a certain time like 1970 or something like that. But anyway, it's not here nor there. But basically, it's the current time in seconds.

I'm adding this item called 'cart item', and then the item is called 'sunglasses'. But as we saw here, this could be whatever the item is. So you just detect that item with the element ID and you can place that as a tag or whatever you like. And then the 'cart updates' is the second tag and that's what the UNIX timestamp is.

So here I have this Callback method that says that, "Okay, what tags were just sent so we can actually log that?" So we just sent the tags. Cart item is sunglasses and cart update is the current time in seconds. In the OneSignal dashboard, I refresh the page, and my device now has ‘cart item is sunglasses and cart update is the current UNIX timestamp in seconds’. Now what's really cool here is I can create segmentation. I can create automated messages that drip on users after 12 hours or 2 hours or 72 hours, however long you want.

After this tag was added, I can now automatically send a notification saying, "Hey, don't forget. You left your sunglasses in your cart." I can just put cart item in the notification and it will be replaced with whatever's here. So our documentation on abandoned cart goes over this exact use case. But I just wanted to show you that it's really not that much code or really that hard to do, and a lot of it is already provided for you. So our documentation is actually full of code examples that you can literally copy-paste into your site. You just need to know where to put it. But once you know where to put it, you can just add it and let it go.

As soon as the user comes back to the site, let's say they make their purchase or let's say they remove the item from the cart, there's also a delete tags method which you can actually use. You just give it the tag keys and it will then delete the tags. So, that's what I have set up here. They purchased or removed the item from the cart. So the callback, delete the tags, cart item, and cart update, and now those tags are gone. Cool.

So that's just the really kind of basic examples of adding tags or things like that. What's really interesting is that if you started to go into ideas around like, "Hey, I have multiple categories, how do I implement that in my site? I want to know all my users that have viewed a certain category X amount of times. Or I want to know all my users that click the push notification recently. Or I want to know all my users what page they subscribed on or what author, what blog author or what article author or article topic or article title," anything you want, you can add tags. As long as the user is subscribed to notifications on your site and that's when the record is created in OneSignal, then once you start calling these tagging methods, the texts just start getting added automatically.

Examples Using Data Tags

[15:32]

These examples, it's happening when I actually click these buttons. But for example, I have this more tagging page here. On this page, I have this example of a subscription page. So on this page, if I were to subscribe on this page, my device will actually get tagged automatically with the pathname of the URL. So, in this case, it'll get tagged with tagging, page author, which I set here as Mark Twain, and then the page topic, so the subscription page topic, which I have here is American Classics.

So just to represent how that works, I'm going to unsubscribe for my site. The way to do that is you go to the lock button. You click ASK here. This is changing the notification permissions back to ASK. I then remove my cookies, and refresh the page. I'm like a first time user. Here’s the bell button, I click it and then click ALLOW. I just got subscribed and it sees I have some logging here, and the user subscription state is now true. So that means I just subscribed. And then I just got tagged with subpage tagging Mark Twain and American Classics.

And then just to make sure this happened in the OneSignal dashboard, I want to make sure I get my player ID. So this is the new OneSignal player ID, the new record for my device. I can just copy that, paste it here. Here's my new user record. So here's the current date and time that I subscribed and this is the last time I was active on the site since my subscription record was created, how many sessions. Here’s my player ID and here's my tags. So here's my subscription page. I got my tagging. The topic was American Classics, and then the author was Mark Twain. Cool.

So, that's how you can tag users based on the page that they subscribed on. In our documentation under Features, and then Use Cases & Best Practices, we have the example code. So I can auto-segment by subscription page. Here's basically the exact same code I just used on my site.

Let's also take a look at page visit. So I want to know, for all my pages, how many times they visited each page and automatically tag them once they visit a certain topic three times. So it's not super beneficial to tag them the first time they visit a topic but upon the third time or second or 10th time. If I go to a certain topic that many times, then I must like that topic and it'd be a good idea to tag them. So in that case, on my site, I have... What did I call it? Topic. I called it... Here we go, page topic. Actually, no. This is for when I click the notification. Okay. Topic visits, here we go.

So in this case, what I'm doing is I'm tagging the user. Let’s just say that this topic of the page is called 'sports'. So I have a sports blog or I have a blog with many different topics. This specific topic is sports. Maybe I have finance, I have breaking news, I have technology, but in this part of my blog or on this part of my website, I talk about sports a lot. So when the person views this page three times, I want to tag that information because I want to know that, okay, my heavy sports readers, I want to send them notifications about sports. So in this case, once they visit this page three times, I'm going to tag them with sports equals to 3.

So the way that that works is I visited the page once, here's my second page visit, and then here's the third time I visit a page. In that case, the tags should have gotten added. I go back to my user record, I refresh the page, and it's not there. In that case, let's see what happened. Maybe I just need to refresh the page. Here we go. Okay. Sorry. I had one more visit. So it was on the fourth time. I subscribed the first time, which didn't count as a session because that was the first time. So this is actually the third time of visiting after subscribing. I got the 'sports: 3'. Let's verify that here... Sports: 3, yup. Cool. So it was the third time visiting a sports article after being subscribed. It makes sense. Cool.

[20:32]

So now, how does this all work? Okay, that's great that the tags are there, but let's see what we can do with this information. Well, also just to go back real quick, I'm going to add this item to the cart as well. Cool. So now, I have the cart update tag as well. Cool.

So now that the information is there, what I can do is I can create segments with this information. So let's say I want to target all my users. I use the user tag 'Filter', and I want to do my sports over 4. So all my users that have the sports tag, and I want to say is greater than 3. So this is greater than, right? So my device is actually not part of this segment yet because it's at 3. It's not over three. If I wanted to, I could have done greater than 2. But in this case, I wanted to do greater than 3.

So for that to happen, all I have to do really is I keep browsing the site and I go to another sports page. And upon visiting that sports page again, the tag got updated. So now, my device has sports: 4. just to verify, I come back here, give it a second. It will update. There you go. There's my device. And just to make sure, here's my device sports > 4. Sorry, greater than 3. Make sure you label your segments correctly better than I'm doing. Back here, I click this, and here is my device record. Sports is 4. I can go back here. I just refresh the page or I visit another article related to sports. Sports is now 5.

The reason this is important is because, if I wanted to target my users that are really active on my sports channel, but they're not really active on my other channels, then I want to keep them happy and I want to send them notifications about sports. If I talk about sports and technology on my blog, well, they might not care about technology, so why would I send them notifications about it? Until they actually start viewing other parts of my blog about technology, then they can decide that behavior, not me. So in my case, I just want to target my users that love sports and I'll send them more and more articles about sports. Maybe I'll send them some technology articles if I really think that it's important. But in this case, sports is what they want.

Now, let's take just one more look at tags. The way that tags work is, you can say sports is something. So I can say like, if I want to target all my users that really like the subscription topic, American Classics, I can say subscription topic is American Classics, right? Or subscription author is Mark Twain or whoever. I can target all my users with that specific tag. So that tag key is a specific value. I can say that tag key is not a specific value. So any users that don't have the subtopic American classics will be in this segment. I can say that the topic exists. So as long as this tag exists, no matter what the value is, target those users. If it does not exist, all my users don't have this.

There's just a lot of different things you can do. You can do integer values, you can do the greater than or less than as we saw earlier. But then we have this cool 'time elapsed' feature. So I want to know all my users that updated their carts on my website and it's been longer than an hour. And then this is in seconds. So however long an hour is in seconds, 60 seconds in a minute times 60 minutes in an hour equals 3,600. So, that should have been easy math. 3,600. So after one hour, my device will actually be added into this segment. I can actually set up an automated message to send to the user saying, "Hey, you left your..." In this case, I could say, "You left your sunglasses in the cart. Come back to finish it." When they click-click that notification, I can lead them back into their shopping cart where they could finish the purchase.

So, that's what I wanted to show. I see that there's some questions in the Q and A so I'll go over and look at those.

[25:12]

Karima: Thank you, Jon. So we have some really good questions here. The first one is: Is there a limit to how many tags can be created?

Jon: There are two limits. One, on free accounts, you have a limit of 10 tags total per device. So you can actually tag a user up to 10 tags. So this is one tag here. This is a tag 2, tag 3, tag 4, tag 5, and tag 6. I can add four more tags if I had a free account. If you have a paid account, there's a system limit of 1,000 tags. Now, we don't recommend adding a thousand tags to users for reasons around performance reasons, making sure everything is running quickly. If you're adding a thousand tags to a user, then you probably want to be using a database for that. In that case, you can actually target users from our API using player ID or you can send us your database ID called external user ID.

Karima: Awesome. Thanks, Jon. Next question is: How do I ensure that sendTag method don't fail when a user has not enabled notifications from the website?

Jon: If a user is not subscribed on your website, the tag code won't run because the tags can only get added to a user if they actually subscribed to the site. Also, within our tagging methods, there's a Callback. So if a user subscribes and then does an action, but they leave the page or something like that before the tag gets added, each tag method has a callback that you can use to view if that tag got added properly. If it didn't, then you can actually use our getTags method to see all the tags on a user and then just re-add the tag if it didn't get at it.

Karima: Awesome. The next question is: Can you show an example using a username tag in an automated message?

Jon: Yeah. Cool. So, let's go back to the main page here. I'll just call this 'user name' and I'll say, this is 'Karima'. Cool. So I just tagged the user with username 'Karima'. In my device record, just to double-check, is there a username Karima. Great. So then the way that that works is - I'm just going to open up a new page - in my messages, this could be done in a template, it can be done just like a normal push notification right away, it can be done through our API as well. I wanted to say, "Hey username, new updates available. Don’t..." You know what, let's just say, "Hey, username, you left your sunglasses in the cart. Come back to finish the purchase."

So, when you send this notification, if I get it right now, because my user record says Karima or it says Jon or whoever, it'll say, "Hey Jon or Hey..." In this case, we'll say, "Hey Karima, you left your sunglasses in the cart. Come back and finish the purchase." So this is kind of the sendTags you use for that tag substitution.

But what's also cool is that you can actually put a default. So if I wanted to, I could put a default "Hey you." Hey is aggressive, but, "Hey there, you left your..." And if you don't have actual cart item, you probably won't want to send this, but you could say you left your... I can just say items, default items in the cart. So if the user doesn't have this username tag or this cart item tag, it's just going to default to using this. That's how it will actually look on the screen.

In fact, I'll go ahead and send this. You're not going to see it on this screen because actually we have two screens going on. But once it actually goes through - refresh the page, delivered - it should be here and it says, "Hey Karima, you left your sunglasses in the cart." So I don't want to share all my messages going on, but you can see it here that it had Karima's name and then it had the sunglasses in the cart. So pretty cool. I hope that helps answer your question.

Karima: The next question is from Benjamin. Can you have multiple tags for one segment? For example, segment equal podcast, techy equal [30:40 inaudible] experience, tag value equal one?

[30:45]

Jon: Yeah, absolutely. When you go to create a segment, and I want to target all those users with those specific tags.... It looks like the... Well, anyways. Yeah. So in this case, I want to target my users that have the carts update tag and I can say 'if that exists'. And then I just do an 'and' operator. So segments can have and/or clauses. So I do that with user tag. What was another one I had? Sub-author is Mark Twain. And then another tag is... let's just say the username is Karima, or let's just say sports, and sports is less than 100.

So yeah, you can absolutely create segments with multiple data filters. It doesn't have to be tags either. I can throw in there like, and their country is whatever country, or I can throw in there their session counts and they've been on the app or website more than two times. So you can do all that with segments. We have a really great article with videos about segmentation in our documentation. This will be under the Using OneSignal, and then Users & Subscribers Guide. And then this talks about all about users and how they work and then segments. Cool.

Karima: Perfect. So the next question is from Marlon. How do we implement tags through Google Tag Manager? I believe we do have a video around Google Tag Manager Implementation. But if you wanted to give a quick overview, that'd be great.

Jon: In the exact same way that you add code to your site, you just add that same code to Google tag manager. Like in my site here, here's that function that I have to tag the user when they click this button. You can just literally copy-paste this into Google Tag Manager, and then it's the exact same thing.

Karima: Perfect. So the next question is from Fabrizio. How do I use tags within my subdomains? For instance, once they know .com/xxx/yyyy, I believe it's tags substitution for URLs. Correct me if I'm wrong, Fabrizio.

Jon: So, from what I'm understanding is you want to send a notification to users that if they have a certain tag, then they go to that URL? or are you wanting to just... Because you can add the tags. As long as the OneSignal code is initialized on the page, you can add the tag and code.

Karima: I think what he means is, you know how we did tags substitution in the content itself, in the message? So is there a way to do it in the URL, like the launch URL?

Jon: Yes, you can. So currently, tags substitution works within the title. It works within the title here. So I can do tags substitution here, username, whatever tag here. And then it's also in the launch URL here. So I can do https://onesignal.com/blog/((b... posts)), whatever tag you want. You can't put the full URL. So I can't tag the user with like https://mysite.com as the actual. So this won't work here. Just doing that won't work. You actually have to put https://, and then everything else can work. So this is the minimum. You'll need to have this in the launch URL. So don't tag the user with this part. But everything after this part you can use as a tag, and if it's a valid URL and the user clicks it, they'll actually get sent to that URL.

[35:23]

Karima: Perfect. So we are a little bit over time here, so I'm just going to pick two to three more, and anything else, we can follow up after with the recording. So the next question is: Is there a way to automate tech creation?

Jon: I mean, yes. Tags, it's just code on your site. So once you add that code, I mean, this is baked into my site right now. So if anybody goes to my site and clicks these buttons, these tags will get added. These input fields, they were just like as an example for testing just to add stuff to it. So you probably won't have that, but you might. Maybe you have a form that says like, "Hey, what's your name?" And the person's like, "Oh, my name is Jon." Then on your end, you might have, the key is username already, so this won't even be there. But in this field, you'll just tag them with their actual name.

Also, just to highlight this question real quick: Would there be a performance issue for sites with 100k daily users? No. There shouldn't be any performance issues.

It looks like each tag requires the addition of code to the site. Yeah. So right now tags, you need code on the site. The only way right now that you don't need to add code is if you have a Shopify website. We do have a Shopify app that automatically handles tags for the abandoned cart. But right now, you will need to add code to your site if you want to do tags. However, we are working on a tag model so you know how we have that slide prompts. We are adding the ability to add tags within that. Maybe I shouldn't say that on the webinar because it's not available yet, but it is something we're working on.

Do tags work for emails? No. The user must be on your website or mobile app with the OneSignal SDK active for tags to be added.

How do you get their name in the first place on the website? Usually, you have a form like this. So you ask the user, "Hey, what's your name?" or "Tell us about yourself," or "What's your profile information?" Or if they're using a Facebook or Google login, they have the information and that might be available. So we don't automatically capture the user's name. The user has to give you that information. And usually, it's in the form of a text field or you just capture it through whatever other avenues you have on your site.

Karima: Perfect. There was one last question from Rex, but I don't believe we have a solution for this. He posted it in a chat: How to set up automatic push messages daily at a certain time?

Jon: How to set up automatic messages daily at a certain time? Well, we do have the ability to create automated messages. And within that feature, there's an option to send it at a specific user's time zone. So if you wanted all your messages to go out at 4:00 PM in each user's time zone, you can create an automated message based on that. The way that an automated message works is that you define your audience, your segment.

So maybe this is my segment here. Great. I'll just call it 'tag segment for the video'. I then create a template. A template is what we just saw earlier with a notification, but it's basically like a reusable notification. I'll call this 'tag template' example', "hey there." Save, and then automated message. I just combined those together with my 'tag example'. I use my tag example template and I target my tag segment. I want this to go out to each user at 12:00 PM in their local time zone and I want this to repeat every 24 hours. So every 24 hours, if the user is still in this segment, they will get this notification at 12:00 PM in their local time zone. Or if I wanted to, I could just do like when the user returns to the app, if they're still in this segment, then they will get this every time they return to the app at 12:00 PM in their local time zone.

A quick note on automated messages: These are not 'and' these are 'or' combination. So if I did this, it would be the user returns to the app. They'll get this if they're still in the segment at 12:00 PM or 24 hours later. So they don't have to return to the app in this case. Just 24 hours later, if they're still in this segment, they'll get the message at 12:00 PM in their local time zone.

[40:18]

Karima: I think we covered all the questions. If you were curious about how to use automated messages, do check out our YouTube channel. We did a webinar about it just two weeks ago. Yeah, but thank you. We will follow up with you the recording. Thanks, Jon for hosting. This was great. If you have any follow-up questions, do let us know. After I follow up with your email, just respond to the email and I'll make sure to answer your questions. Yeah, thanks, everyone, for joining.

Jon: Also, the webinars are usually posted in our docs here, but yeah. Thanks, everybody. Have a great day.

Karima: Bye.