Converting the string value "'x' ms" into an integer - Video Tracking

Gold Contributor
Gold Contributor

Could anyone help me on the below query,

 

In GUA - How to capture video playback time by converting the string value "'x' ms" into an integer using Extension?

 

It would be great if i receive answer asap.

 

Thanks in advance!

5 REPLIES 5

Converting the string value "'x' ms" into an integer - Video Tracking

Moderator
Moderator
Hi,

This should work:

Use a "set data values" extension, and set the type to JS Code. In the box on the left, select the data source you want to modify (or create a new one, if you don't want to overwrite the old one). Let's assume your data source is called "runtime". In the text field on the right, enter this code:

parseInt(b.runtime);

parseInt will covert your string to an integer and remove any text that is not a valid integer.
Hope this helps.

Craig.
Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.

Converting the string value "'x' ms" into an integer - Video Tracking

Gold Contributor
Gold Contributor

Thanks for your valuable inputs Craig.

 

I just want to confirm with you that, here you can see that i'm capturing below values when i pause the video,

 

Event Action (ea): Pause
Event Category (ec): xyz
Event Label (el): xyz - Video | 65095 ms
Event Value (ev): 65095 ms

 

"Event value" contains string value as 65095ms instead of i should get the "Integer value". Based on your mail, shall i go ahead and overwrite the "Event Value" or should i create a New Data Source as "runtime". Suggest me the best practice to solve this issue.

 

 

Please help me on this. Thanks in advance!

Converting the string value "'x' ms" into an integer - Video Tracking

Moderator
Moderator

Hi,

 

If you need the string value for other tags, then it's best to create a new data source so that you have both the integer and string representations available.

 

If, however, you are only using this value for Google Analytics, and you don't care about the string value "65000 ms", then go ahead and overwrite the existing data source. It all depends on what you want to do with the data. I would probably go with creating a new data source for maximum flexibility, but it's really up to you.

Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.

Converting the string value "'x' ms" into an integer - Video Tracking

Gold Contributor
Gold Contributor

Thank you so much Craig.

 

Sure, i will go ahead with the second points which you suggested. But the rule is generic however – there is no condition behind it.

 

Is that possible, can we add in a "Condition" so that it’s used specifically with the video timing?. If yes, could you please provide solutioms with SCREENSHOT of Tealium IQ interface on this.

 

 

Converting the string value "'x' ms" into an integer - Video Tracking

Moderator
Moderator

Hi again @Srinivasan,

 

Sorry it's taken a while to answer your latest question.

 

You could add a condition based on the event action you're passing in, e.g. "Video Pause" or "Video Play". It's very simple to add conditions to the "Set Data Values" extension. Please see here for the full documentation: https://community.tealiumiq.com/t5/Developers/Set-Data-Values-Extension/m-p/1611/highlight/true#M375...

 

I hope this helps - do let me know if you need anything else.

 

Craig.

Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.
Public